-
-
Notifications
You must be signed in to change notification settings - Fork 931
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: identity credential identifiers are now unique per method
- Loading branch information
Showing
82 changed files
with
164 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
persistence/sql/migrations/sql/20210410175418000063_network.sqlite3.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +0,0 @@ | ||
DROP INDEX IF EXISTS "selfservice_login_flows_nid_idx"; | ||
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000000_unique_credentials.cockroach.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CREATE UNIQUE INDEX "identity_credential_identifiers_identifier_nid_uq_idx" ON "identity_credential_identifiers" (nid, identifier); |
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000000_unique_credentials.cockroach.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP INDEX IF EXISTS "identity_credential_identifiers_identifier_nid_uq_idx"; |
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000000_unique_credentials.mysql.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CREATE UNIQUE INDEX `identity_credential_identifiers_identifier_nid_uq_idx` ON `identity_credential_identifiers` (`nid`, `identifier`); |
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000000_unique_credentials.mysql.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE identity_credential_identifiers DROP FOREIGN KEY identity_credential_identifiers_nid_fk_idx; |
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000000_unique_credentials.postgres.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CREATE UNIQUE INDEX "identity_credential_identifiers_identifier_nid_uq_idx" ON "identity_credential_identifiers" (nid, identifier); |
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000000_unique_credentials.postgres.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP INDEX "identity_credential_identifiers_identifier_nid_uq_idx"; |
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000000_unique_credentials.sqlite3.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CREATE UNIQUE INDEX "identity_credential_identifiers_identifier_nid_uq_idx" ON "identity_credential_identifiers" (nid, identifier); |
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000000_unique_credentials.sqlite3.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP INDEX IF EXISTS "identity_credential_identifiers_identifier_nid_uq_idx"; |
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000001_unique_credentials.cockroach.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE "identity_credential_identifiers" DROP COLUMN "identity_credential_type_id"; |
2 changes: 2 additions & 0 deletions
2
persistence/sql/migrations/sql/20210817181232000001_unique_credentials.cockroach.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE "identity_credential_identifiers" | ||
ADD COLUMN "identity_credential_type_id" UUID; |
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000001_unique_credentials.mysql.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE `identity_credential_identifiers` DROP COLUMN `identity_credential_type_id`; |
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000001_unique_credentials.mysql.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP INDEX `identity_credential_identifiers_identifier_nid_uq_idx` ON `identity_credential_identifiers`; |
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000001_unique_credentials.postgres.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE "identity_credential_identifiers" DROP COLUMN "identity_credential_type_id"; |
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000001_unique_credentials.postgres.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE "identity_credential_identifiers" ADD COLUMN "identity_credential_type_id" UUID; |
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000001_unique_credentials.sqlite3.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE "_identity_credential_identifiers_tmp" RENAME TO "identity_credential_identifiers"; |
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000001_unique_credentials.sqlite3.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE "identity_credential_identifiers" ADD COLUMN "identity_credential_type_id" char(36); |
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000002_unique_credentials.cockroach.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP INDEX IF EXISTS "identity_credential_identifiers_identifier_nid_type_uq_idx"; |
2 changes: 2 additions & 0 deletions
2
persistence/sql/migrations/sql/20210817181232000002_unique_credentials.cockroach.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE "identity_credential_identifiers" | ||
ADD CONSTRAINT "identity_credential_identifiers_type_id_fk_idx" FOREIGN KEY ("identity_credential_type_id") REFERENCES "identity_credential_types" ("id") ON UPDATE RESTRICT ON DELETE CASCADE; |
2 changes: 2 additions & 0 deletions
2
persistence/sql/migrations/sql/20210817181232000002_unique_credentials.mysql.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE `identity_credential_identifiers` | ||
ADD CONSTRAINT `identity_credential_identifiers_nid_fk_idx` FOREIGN KEY (`nid`) REFERENCES `networks` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE; |
2 changes: 2 additions & 0 deletions
2
persistence/sql/migrations/sql/20210817181232000002_unique_credentials.mysql.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE `identity_credential_identifiers` | ||
ADD CONSTRAINT `identity_credential_identifiers_nid_fk_idx` FOREIGN KEY (`nid`) REFERENCES `networks` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE; |
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000002_unique_credentials.postgres.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP INDEX "identity_credential_identifiers_identifier_nid_type_uq_idx"; |
2 changes: 2 additions & 0 deletions
2
persistence/sql/migrations/sql/20210817181232000002_unique_credentials.postgres.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE "identity_credential_identifiers" | ||
ADD CONSTRAINT "identity_credential_identifiers_type_id_fk_idx" FOREIGN KEY ("identity_credential_type_id") REFERENCES "identity_credential_types" ("id") ON UPDATE RESTRICT ON DELETE CASCADE; |
2 changes: 2 additions & 0 deletions
2
persistence/sql/migrations/sql/20210817181232000002_unique_credentials.sqlite3.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
DROP TABLE "identity_credential_identifiers"; |
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000002_unique_credentials.sqlite3.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE identity_credential_identifiers DROP COLUMN identity_credential_type_id; |
Empty file.
5 changes: 5 additions & 0 deletions
5
persistence/sql/migrations/sql/20210817181232000003_unique_credentials.cockroach.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
UPDATE identity_credential_identifiers | ||
SET identity_credential_type_id = (SELECT ict.id | ||
FROM identity_credential_types as ict | ||
JOIN identity_credentials AS ic ON (ic.identity_credential_type_id = ict.id) | ||
WHERE ic.id = identity_credential_id); |
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000003_unique_credentials.mysql.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP INDEX `identity_credential_identifiers_identifier_nid_type_uq_idx` ON `identity_credential_identifiers`; |
2 changes: 2 additions & 0 deletions
2
persistence/sql/migrations/sql/20210817181232000003_unique_credentials.mysql.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE `identity_credential_identifiers` | ||
ADD COLUMN `identity_credential_type_id` char(36); |
Empty file.
5 changes: 5 additions & 0 deletions
5
persistence/sql/migrations/sql/20210817181232000003_unique_credentials.postgres.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
UPDATE identity_credential_identifiers | ||
SET identity_credential_type_id = (SELECT ict.id | ||
FROM identity_credential_types as ict | ||
JOIN identity_credentials AS ic ON (ic.identity_credential_type_id = ict.id) | ||
WHERE ic.id = identity_credential_id); |
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000003_unique_credentials.sqlite3.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
INSERT INTO "_identity_credential_identifiers_tmp" (id, identifier, identity_credential_id, created_at, updated_at, nid) SELECT id, identifier, identity_credential_id, created_at, updated_at, nid FROM "identity_credential_identifiers"; |
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000003_unique_credentials.sqlite3.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE identity_credential_identifiers ADD COLUMN identity_credential_type_id CHAR(36) NULL REFERENCES identity_credential_types(id) ON DELETE CASCADE ON UPDATE RESTRICT; |
Empty file.
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000004_unique_credentials.cockroach.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE "identity_credential_identifiers" DROP CONSTRAINT "identity_credential_identifiers_type_id_fk_idx"; |
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000004_unique_credentials.mysql.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE identity_credential_identifiers DROP FOREIGN KEY identity_credential_identifiers_type_id_fk_idx; |
2 changes: 2 additions & 0 deletions
2
persistence/sql/migrations/sql/20210817181232000004_unique_credentials.mysql.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE `identity_credential_identifiers` | ||
ADD CONSTRAINT `identity_credential_identifiers_type_id_fk_idx` FOREIGN KEY (`identity_credential_type_id`) REFERENCES `identity_credential_types` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE; |
Empty file.
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000004_unique_credentials.postgres.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE "identity_credential_identifiers" ALTER COLUMN "identity_credential_type_id" TYPE UUID, ALTER COLUMN "identity_credential_type_id" SET NOT NULL; |
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000004_unique_credentials.sqlite3.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CREATE INDEX "identity_credential_identifiers_nid_idx" ON "_identity_credential_identifiers_tmp" (id, nid); |
5 changes: 5 additions & 0 deletions
5
persistence/sql/migrations/sql/20210817181232000004_unique_credentials.sqlite3.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
UPDATE identity_credential_identifiers | ||
SET identity_credential_type_id = (SELECT ict.id | ||
FROM identity_credential_types as ict | ||
JOIN identity_credentials AS ic ON (ic.identity_credential_type_id = ict.id) | ||
WHERE ic.id = identity_credential_id); |
Empty file.
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000005_unique_credentials.cockroach.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE "identity_credential_identifiers" RENAME COLUMN "identity_credential_type_id" TO "_identity_credential_type_id_tmp"; |
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000005_unique_credentials.mysql.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE identity_credential_identifiers DROP FOREIGN KEY identity_credential_identifiers_nid_fk_idx; |
5 changes: 5 additions & 0 deletions
5
persistence/sql/migrations/sql/20210817181232000005_unique_credentials.mysql.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
UPDATE identity_credential_identifiers | ||
SET identity_credential_type_id = (SELECT ict.id | ||
FROM identity_credential_types as ict | ||
JOIN identity_credentials AS ic ON (ic.identity_credential_type_id = ict.id) | ||
WHERE ic.id = identity_credential_id); |
Empty file.
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000005_unique_credentials.postgres.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CREATE UNIQUE INDEX "identity_credential_identifiers_identifier_nid_type_uq_idx" ON "identity_credential_identifiers" (nid, identity_credential_type_id, identifier); |
9 changes: 9 additions & 0 deletions
9
persistence/sql/migrations/sql/20210817181232000005_unique_credentials.sqlite3.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CREATE TABLE "_identity_credential_identifiers_tmp" ( | ||
"id" TEXT PRIMARY KEY, | ||
"identifier" TEXT NOT NULL, | ||
"identity_credential_id" char(36) NOT NULL, | ||
"created_at" DATETIME NOT NULL, | ||
"updated_at" DATETIME NOT NULL, | ||
"nid" char(36), | ||
FOREIGN KEY (identity_credential_id) REFERENCES identity_credentials (id) ON UPDATE NO ACTION ON DELETE CASCADE | ||
); |
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000005_unique_credentials.sqlite3.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP INDEX IF EXISTS "identity_credential_identifiers_nid_idx"; |
Empty file.
2 changes: 2 additions & 0 deletions
2
persistence/sql/migrations/sql/20210817181232000006_unique_credentials.cockroach.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE "identity_credential_identifiers" | ||
ADD COLUMN "identity_credential_type_id" UUID; |
Empty file.
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000006_unique_credentials.mysql.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE `identity_credential_identifiers` MODIFY `identity_credential_type_id` char (36) NOT NULL; |
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000006_unique_credentials.sqlite3.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP INDEX IF EXISTS "identity_credential_identifiers_nid_idx"; |
11 changes: 11 additions & 0 deletions
11
persistence/sql/migrations/sql/20210817181232000006_unique_credentials.sqlite3.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
CREATE TABLE "_identity_credential_identifiers_tmp" | ||
( | ||
"id" TEXT PRIMARY KEY, | ||
"identifier" TEXT NOT NULL, | ||
"identity_credential_id" char(36) NOT NULL, | ||
"created_at" DATETIME NOT NULL, | ||
"updated_at" DATETIME NOT NULL, | ||
"nid" char(36), | ||
"identity_credential_type_id" char(36) NOT NULL, | ||
FOREIGN KEY (identity_credential_id) REFERENCES identity_credentials (id) ON UPDATE NO ACTION ON DELETE CASCADE | ||
); |
Empty file.
2 changes: 2 additions & 0 deletions
2
persistence/sql/migrations/sql/20210817181232000007_unique_credentials.cockroach.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
UPDATE "identity_credential_identifiers" | ||
SET "identity_credential_type_id" = "_identity_credential_type_id_tmp"; |
Empty file.
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000007_unique_credentials.mysql.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CREATE UNIQUE INDEX `identity_credential_identifiers_identifier_nid_type_uq_idx` ON `identity_credential_identifiers` (`nid`, `identity_credential_type_id`, `identifier`); |
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000007_unique_credentials.sqlite3.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP INDEX IF EXISTS "identity_credential_identifiers_identifier_nid_type_uq_idx"; |
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000007_unique_credentials.sqlite3.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CREATE INDEX "identity_credential_identifiers_nid_idx" ON "_identity_credential_identifiers_tmp" (id, nid); |
Empty file.
2 changes: 2 additions & 0 deletions
2
persistence/sql/migrations/sql/20210817181232000008_unique_credentials.cockroach.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE "identity_credential_identifiers" | ||
ALTER COLUMN "identity_credential_type_id" SET NOT NULL; |
Empty file.
4 changes: 4 additions & 0 deletions
4
persistence/sql/migrations/sql/20210817181232000008_unique_credentials.sqlite3.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
INSERT INTO "_identity_credential_identifiers_tmp" (id, identifier, identity_credential_id, created_at, updated_at, nid, | ||
identity_credential_type_id) | ||
SELECT id, identifier, identity_credential_id, created_at, updated_at, nid, identity_credential_type_id | ||
FROM "identity_credential_identifiers"; |
Empty file.
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000009_unique_credentials.cockroach.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE "identity_credential_identifiers" DROP COLUMN "_identity_credential_type_id_tmp"; |
Empty file.
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000009_unique_credentials.sqlite3.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP TABLE "identity_credential_identifiers"; |
Empty file.
2 changes: 2 additions & 0 deletions
2
persistence/sql/migrations/sql/20210817181232000010_unique_credentials.cockroach.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE "identity_credential_identifiers" | ||
ADD CONSTRAINT "identity_credential_identifiers_type_id_fk_idx" FOREIGN KEY ("identity_credential_type_id") REFERENCES "identity_credential_types" ("id") ON UPDATE RESTRICT ON DELETE CASCADE; |
Empty file.
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000010_unique_credentials.sqlite3.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE "_identity_credential_identifiers_tmp" RENAME TO "identity_credential_identifiers"; |
Empty file.
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000011_unique_credentials.cockroach.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CREATE UNIQUE INDEX "identity_credential_identifiers_identifier_nid_type_uq_idx" ON "identity_credential_identifiers" (nid, identity_credential_type_id, identifier); |
Empty file.
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20210817181232000011_unique_credentials.sqlite3.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CREATE UNIQUE INDEX "identity_credential_identifiers_identifier_nid_type_uq_idx" ON "identity_credential_identifiers" (nid, identity_credential_type_id, identifier); |
18 changes: 18 additions & 0 deletions
18
persistence/sql/migrations/templates/20210817181232_unique_credentials.down.fizz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{{ if .IsMySQL }} | ||
sql("ALTER TABLE identity_credential_identifiers DROP FOREIGN KEY identity_credential_identifiers_nid_fk_idx") | ||
sql("ALTER TABLE identity_credential_identifiers DROP FOREIGN KEY identity_credential_identifiers_type_id_fk_idx") | ||
{{ end }} | ||
|
||
drop_index("identity_credential_identifiers","identity_credential_identifiers_identifier_nid_type_uq_idx") | ||
|
||
{{ if .IsMySQL }} | ||
add_foreign_key("identity_credential_identifiers", "nid", {"networks": ["id"]}, { | ||
"name": "identity_credential_identifiers_nid_fk_idx", | ||
"on_delete": "CASCADE", | ||
"on_update": "RESTRICT", | ||
}) | ||
{{ end }} | ||
|
||
drop_column("identity_credential_identifiers", "identity_credential_type_id") | ||
|
||
add_index("identity_credential_identifiers", ["nid", "identifier"], {"unique": true, "name": "identity_credential_identifiers_identifier_nid_uq_idx"}) |
31 changes: 31 additions & 0 deletions
31
persistence/sql/migrations/templates/20210817181232_unique_credentials.up.fizz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{{ if .IsMySQL }} | ||
sql("ALTER TABLE identity_credential_identifiers DROP FOREIGN KEY identity_credential_identifiers_nid_fk_idx") | ||
{{ end }} | ||
|
||
drop_index("identity_credential_identifiers", "identity_credential_identifiers_identifier_nid_uq_idx") | ||
|
||
{{ if .IsMySQL }} | ||
add_foreign_key("identity_credential_identifiers", "nid", {"networks": ["id"]}, { | ||
"name": "identity_credential_identifiers_nid_fk_idx", | ||
"on_delete": "CASCADE", | ||
"on_update": "RESTRICT", | ||
}) | ||
{{ end }} | ||
|
||
add_column("identity_credential_identifiers", "identity_credential_type_id", "uuid", { "null": true }) | ||
|
||
{{ if .IsSQLite }} | ||
sql("ALTER TABLE identity_credential_identifiers DROP COLUMN identity_credential_type_id") | ||
sql("ALTER TABLE identity_credential_identifiers ADD COLUMN identity_credential_type_id CHAR(36) NULL REFERENCES identity_credential_types(id) ON DELETE CASCADE ON UPDATE RESTRICT") | ||
{{ else }} | ||
add_foreign_key("identity_credential_identifiers", "identity_credential_type_id", {"identity_credential_types": ["id"]}, { | ||
"name": "identity_credential_identifiers_type_id_fk_idx", | ||
"on_delete": "CASCADE", | ||
"on_update": "RESTRICT", | ||
}) | ||
{{ end }} | ||
|
||
sql("UPDATE identity_credential_identifiers SET identity_credential_type_id = (SELECT ict.id FROM identity_credential_types as ict JOIN identity_credentials AS ic ON (ic.identity_credential_type_id = ict.id) WHERE ic.id = identity_credential_id)") | ||
|
||
change_column("identity_credential_identifiers", "identity_credential_type_id", "uuid", {}) | ||
add_index("identity_credential_identifiers", ["nid", "identity_credential_type_id", "identifier"], {"unique": true, "name": "identity_credential_identifiers_identifier_nid_type_uq_idx"}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters