mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 14:47:33 +00:00
fixup! fixup! feat(db): Adding identity_providers table for relational database
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package migration
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
)
|
||||
|
||||
var (
|
||||
//go:embed 003_identity_providers_table/up.sql
|
||||
up003IdentityProvidersTable string
|
||||
//go:embed 003_identity_providers_table/down.sql
|
||||
down003IdentityProvidersTable string
|
||||
)
|
||||
|
||||
func init() {
|
||||
registerSQLMigration(3, up003IdentityProvidersTable, down003IdentityProvidersTable)
|
||||
}
|
@@ -14,12 +14,12 @@ CREATE TYPE idp_type AS ENUM (
|
||||
'apple'
|
||||
);
|
||||
|
||||
CREATE TABLE identity_providers (
|
||||
CREATE TABLE zitadel.identity_providers (
|
||||
instance_id TEXT NOT NULL
|
||||
, org_id TEXT
|
||||
, id TEXT NOT NULL
|
||||
, id TEXT NOT NULL CHECK (id <> '')
|
||||
, state idp_state NOT NULL DEFAULT 'active'
|
||||
, name TEXT
|
||||
, name TEXT NOT NULL CHECK (name <> '')
|
||||
, type idp_type NOT NULL
|
||||
, allow_creation BOOLEAN NOT NULL DEFAULT TRUE
|
||||
, allow_auto_creation BOOLEAN NOT NULL DEFAULT TRUE
|
||||
@@ -32,14 +32,15 @@ CREATE TABLE identity_providers (
|
||||
, updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
|
||||
, PRIMARY KEY (instance_id, id)
|
||||
, CONSTRAINT identity_providers_unique UNIQUE NULLS NOT DISTINCT (instance_id, org_id, id)
|
||||
, FOREIGN KEY (instance_id) REFERENCES instances(id)
|
||||
, FOREIGN KEY (instance_id, org_id) REFERENCES organizations(instance_id, id)
|
||||
, CONSTRAINT identity_providers_id_unique UNIQUE NULLS NOT DISTINCT (instance_id, org_id, id)
|
||||
, CONSTRAINT identity_providers_name_unique UNIQUE NULLS NOT DISTINCT (instance_id, org_id, name)
|
||||
, FOREIGN KEY (instance_id) REFERENCES zitadel.instances(id)
|
||||
, FOREIGN KEY (instance_id, org_id) REFERENCES zitadel.organizations(instance_id, id)
|
||||
);
|
||||
|
||||
-- CREATE INDEX idx_identity_providers_org_id ON identity_providers(instance_id, org_id) WHERE org_id IS NOT NULL;
|
||||
CREATE INDEX idx_identity_providers_state ON identity_providers(instance_id, state);
|
||||
CREATE INDEX idx_identity_providers_type ON identity_providers(instance_id, type);
|
||||
CREATE INDEX idx_identity_providers_state ON zitadel.identity_providers(instance_id, state);
|
||||
CREATE INDEX idx_identity_providers_type ON zitadel.identity_providers(instance_id, type);
|
||||
-- CREATE INDEX idx_identity_providers_created_at ON identity_providers(created_at);
|
||||
-- CREATE INDEX idx_identity_providers_deleted_at ON identity_providers(deleted_at) WHERE deleted_at IS NOT NULL;
|
||||
|
Reference in New Issue
Block a user