1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 15:42:48 -05:00

Remove EF migration scripts (#2550)

* Removed Scripts folders

* Removed .csproj references.

* Added back HelperScripts

* Added back additional helper scripts.

* Fixed extra ItemGroup
This commit is contained in:
Todd Martin
2023-01-10 13:46:19 -05:00
committed by GitHub
parent ea9e30c35f
commit 145071d499
49 changed files with 12 additions and 1617 deletions

View File

@ -1,497 +0,0 @@
CREATE TABLE IF NOT EXISTS "__EFMigrationsHistory" (
"MigrationId" character varying(150) NOT NULL,
"ProductVersion" character varying(32) NOT NULL,
CONSTRAINT "PK___EFMigrationsHistory" PRIMARY KEY ("MigrationId")
);
START TRANSACTION;
CREATE COLLATION "postgresIndetermanisticCollation" (LC_COLLATE = 'en-u-ks-primary',
LC_CTYPE = 'en-u-ks-primary',
PROVIDER = icu,
DETERMINISTIC = False
);
CREATE TABLE "Event" (
"Id" uuid NOT NULL,
"Date" timestamp without time zone NOT NULL,
"Type" integer NOT NULL,
"UserId" uuid NULL,
"OrganizationId" uuid NULL,
"CipherId" uuid NULL,
"CollectionId" uuid NULL,
"PolicyId" uuid NULL,
"GroupId" uuid NULL,
"OrganizationUserId" uuid NULL,
"DeviceType" smallint NULL,
"IpAddress" character varying(50) NULL,
"ActingUserId" uuid NULL,
CONSTRAINT "PK_Event" PRIMARY KEY ("Id")
);
CREATE TABLE "Grant" (
"Key" character varying(200) NOT NULL,
"Type" character varying(50) NULL,
"SubjectId" character varying(200) NULL,
"SessionId" character varying(100) NULL,
"ClientId" character varying(200) NULL,
"Description" character varying(200) NULL,
"CreationDate" timestamp without time zone NOT NULL,
"ExpirationDate" timestamp without time zone NULL,
"ConsumedDate" timestamp without time zone NULL,
"Data" text NULL,
CONSTRAINT "PK_Grant" PRIMARY KEY ("Key")
);
CREATE TABLE "Installation" (
"Id" uuid NOT NULL,
"Email" character varying(256) NULL,
"Key" character varying(150) NULL,
"Enabled" boolean NOT NULL,
"CreationDate" timestamp without time zone NOT NULL,
CONSTRAINT "PK_Installation" PRIMARY KEY ("Id")
);
CREATE TABLE "Organization" (
"Id" uuid NOT NULL,
"Identifier" character varying(50) COLLATE "postgresIndetermanisticCollation" NULL,
"Name" character varying(50) NULL,
"BusinessName" character varying(50) NULL,
"BusinessAddress1" character varying(50) NULL,
"BusinessAddress2" character varying(50) NULL,
"BusinessAddress3" character varying(50) NULL,
"BusinessCountry" character varying(2) NULL,
"BusinessTaxNumber" character varying(30) NULL,
"BillingEmail" character varying(256) NULL,
"Plan" character varying(50) NULL,
"PlanType" smallint NOT NULL,
"Seats" integer NULL,
"MaxCollections" smallint NULL,
"UsePolicies" boolean NOT NULL,
"UseSso" boolean NOT NULL,
"UseGroups" boolean NOT NULL,
"UseDirectory" boolean NOT NULL,
"UseEvents" boolean NOT NULL,
"UseTotp" boolean NOT NULL,
"Use2fa" boolean NOT NULL,
"UseApi" boolean NOT NULL,
"UseResetPassword" boolean NOT NULL,
"SelfHost" boolean NOT NULL,
"UsersGetPremium" boolean NOT NULL,
"Storage" bigint NULL,
"MaxStorageGb" smallint NULL,
"Gateway" smallint NULL,
"GatewayCustomerId" character varying(50) NULL,
"GatewaySubscriptionId" character varying(50) NULL,
"ReferenceData" text NULL,
"Enabled" boolean NOT NULL,
"LicenseKey" character varying(100) NULL,
"ApiKey" character varying(30) NULL,
"PublicKey" text NULL,
"PrivateKey" text NULL,
"TwoFactorProviders" text NULL,
"ExpirationDate" timestamp without time zone NULL,
"CreationDate" timestamp without time zone NOT NULL,
"RevisionDate" timestamp without time zone NOT NULL,
CONSTRAINT "PK_Organization" PRIMARY KEY ("Id")
);
CREATE TABLE "Provider" (
"Id" uuid NOT NULL,
"Name" text NULL,
"BusinessName" text NULL,
"BusinessAddress1" text NULL,
"BusinessAddress2" text NULL,
"BusinessAddress3" text NULL,
"BusinessCountry" text NULL,
"BusinessTaxNumber" text NULL,
"BillingEmail" text NULL,
"Status" smallint NOT NULL,
"UseEvents" boolean NOT NULL,
"Enabled" boolean NOT NULL,
"CreationDate" timestamp without time zone NOT NULL,
"RevisionDate" timestamp without time zone NOT NULL,
CONSTRAINT "PK_Provider" PRIMARY KEY ("Id")
);
CREATE TABLE "TaxRate" (
"Id" character varying(40) NOT NULL,
"Country" character varying(50) NULL,
"State" character varying(2) NULL,
"PostalCode" character varying(10) NULL,
"Rate" numeric NOT NULL,
"Active" boolean NOT NULL,
CONSTRAINT "PK_TaxRate" PRIMARY KEY ("Id")
);
CREATE TABLE "User" (
"Id" uuid NOT NULL,
"Name" character varying(50) NULL,
"Email" character varying(256) COLLATE "postgresIndetermanisticCollation" NOT NULL,
"EmailVerified" boolean NOT NULL,
"MasterPassword" character varying(300) NULL,
"MasterPasswordHint" character varying(50) NULL,
"Culture" character varying(10) NULL,
"SecurityStamp" character varying(50) NOT NULL,
"TwoFactorProviders" text NULL,
"TwoFactorRecoveryCode" character varying(32) NULL,
"EquivalentDomains" text NULL,
"ExcludedGlobalEquivalentDomains" text NULL,
"AccountRevisionDate" timestamp without time zone NOT NULL,
"Key" text NULL,
"PublicKey" text NULL,
"PrivateKey" text NULL,
"Premium" boolean NOT NULL,
"PremiumExpirationDate" timestamp without time zone NULL,
"RenewalReminderDate" timestamp without time zone NULL,
"Storage" bigint NULL,
"MaxStorageGb" smallint NULL,
"Gateway" smallint NULL,
"GatewayCustomerId" character varying(50) NULL,
"GatewaySubscriptionId" character varying(50) NULL,
"ReferenceData" text NULL,
"LicenseKey" character varying(100) NULL,
"ApiKey" character varying(30) NOT NULL,
"Kdf" smallint NOT NULL,
"KdfIterations" integer NOT NULL,
"CreationDate" timestamp without time zone NOT NULL,
"RevisionDate" timestamp without time zone NOT NULL,
CONSTRAINT "PK_User" PRIMARY KEY ("Id")
);
CREATE TABLE "Collection" (
"Id" uuid NOT NULL,
"OrganizationId" uuid NOT NULL,
"Name" text NULL,
"ExternalId" character varying(300) NULL,
"CreationDate" timestamp without time zone NOT NULL,
"RevisionDate" timestamp without time zone NOT NULL,
CONSTRAINT "PK_Collection" PRIMARY KEY ("Id"),
CONSTRAINT "FK_Collection_Organization_OrganizationId" FOREIGN KEY ("OrganizationId") REFERENCES "Organization" ("Id") ON DELETE CASCADE
);
CREATE TABLE "Group" (
"Id" uuid NOT NULL,
"OrganizationId" uuid NOT NULL,
"Name" character varying(100) NULL,
"AccessAll" boolean NOT NULL,
"ExternalId" character varying(300) NULL,
"CreationDate" timestamp without time zone NOT NULL,
"RevisionDate" timestamp without time zone NOT NULL,
CONSTRAINT "PK_Group" PRIMARY KEY ("Id"),
CONSTRAINT "FK_Group_Organization_OrganizationId" FOREIGN KEY ("OrganizationId") REFERENCES "Organization" ("Id") ON DELETE CASCADE
);
CREATE TABLE "Policy" (
"Id" uuid NOT NULL,
"OrganizationId" uuid NOT NULL,
"Type" smallint NOT NULL,
"Data" text NULL,
"Enabled" boolean NOT NULL,
"CreationDate" timestamp without time zone NOT NULL,
"RevisionDate" timestamp without time zone NOT NULL,
CONSTRAINT "PK_Policy" PRIMARY KEY ("Id"),
CONSTRAINT "FK_Policy_Organization_OrganizationId" FOREIGN KEY ("OrganizationId") REFERENCES "Organization" ("Id") ON DELETE CASCADE
);
CREATE TABLE "SsoConfig" (
"Id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"Enabled" boolean NOT NULL,
"OrganizationId" uuid NOT NULL,
"Data" text NULL,
"CreationDate" timestamp without time zone NOT NULL,
"RevisionDate" timestamp without time zone NOT NULL,
CONSTRAINT "PK_SsoConfig" PRIMARY KEY ("Id"),
CONSTRAINT "FK_SsoConfig_Organization_OrganizationId" FOREIGN KEY ("OrganizationId") REFERENCES "Organization" ("Id") ON DELETE CASCADE
);
CREATE TABLE "ProviderOrganization" (
"Id" uuid NOT NULL,
"ProviderId" uuid NOT NULL,
"OrganizationId" uuid NOT NULL,
"Key" text NULL,
"Settings" text NULL,
"CreationDate" timestamp without time zone NOT NULL,
"RevisionDate" timestamp without time zone NOT NULL,
CONSTRAINT "PK_ProviderOrganization" PRIMARY KEY ("Id"),
CONSTRAINT "FK_ProviderOrganization_Organization_OrganizationId" FOREIGN KEY ("OrganizationId") REFERENCES "Organization" ("Id") ON DELETE CASCADE,
CONSTRAINT "FK_ProviderOrganization_Provider_ProviderId" FOREIGN KEY ("ProviderId") REFERENCES "Provider" ("Id") ON DELETE CASCADE
);
CREATE TABLE "Cipher" (
"Id" uuid NOT NULL,
"UserId" uuid NULL,
"OrganizationId" uuid NULL,
"Type" smallint NOT NULL,
"Data" text NULL,
"Favorites" text NULL,
"Folders" text NULL,
"Attachments" text NULL,
"CreationDate" timestamp without time zone NOT NULL,
"RevisionDate" timestamp without time zone NOT NULL,
"DeletedDate" timestamp without time zone NULL,
"Reprompt" smallint NULL,
CONSTRAINT "PK_Cipher" PRIMARY KEY ("Id"),
CONSTRAINT "FK_Cipher_Organization_OrganizationId" FOREIGN KEY ("OrganizationId") REFERENCES "Organization" ("Id") ON DELETE RESTRICT,
CONSTRAINT "FK_Cipher_User_UserId" FOREIGN KEY ("UserId") REFERENCES "User" ("Id") ON DELETE RESTRICT
);
CREATE TABLE "Device" (
"Id" uuid NOT NULL,
"UserId" uuid NOT NULL,
"Name" character varying(50) NULL,
"Type" smallint NOT NULL,
"Identifier" character varying(50) NULL,
"PushToken" character varying(255) NULL,
"CreationDate" timestamp without time zone NOT NULL,
"RevisionDate" timestamp without time zone NOT NULL,
CONSTRAINT "PK_Device" PRIMARY KEY ("Id"),
CONSTRAINT "FK_Device_User_UserId" FOREIGN KEY ("UserId") REFERENCES "User" ("Id") ON DELETE CASCADE
);
CREATE TABLE "EmergencyAccess" (
"Id" uuid NOT NULL,
"GrantorId" uuid NOT NULL,
"GranteeId" uuid NULL,
"Email" character varying(256) NULL,
"KeyEncrypted" text NULL,
"Type" smallint NOT NULL,
"Status" smallint NOT NULL,
"WaitTimeDays" integer NOT NULL,
"RecoveryInitiatedDate" timestamp without time zone NULL,
"LastNotificationDate" timestamp without time zone NULL,
"CreationDate" timestamp without time zone NOT NULL,
"RevisionDate" timestamp without time zone NOT NULL,
CONSTRAINT "PK_EmergencyAccess" PRIMARY KEY ("Id"),
CONSTRAINT "FK_EmergencyAccess_User_GranteeId" FOREIGN KEY ("GranteeId") REFERENCES "User" ("Id") ON DELETE RESTRICT,
CONSTRAINT "FK_EmergencyAccess_User_GrantorId" FOREIGN KEY ("GrantorId") REFERENCES "User" ("Id") ON DELETE CASCADE
);
CREATE TABLE "Folder" (
"Id" uuid NOT NULL,
"UserId" uuid NOT NULL,
"Name" text NULL,
"CreationDate" timestamp without time zone NOT NULL,
"RevisionDate" timestamp without time zone NOT NULL,
CONSTRAINT "PK_Folder" PRIMARY KEY ("Id"),
CONSTRAINT "FK_Folder_User_UserId" FOREIGN KEY ("UserId") REFERENCES "User" ("Id") ON DELETE CASCADE
);
CREATE TABLE "OrganizationUser" (
"Id" uuid NOT NULL,
"OrganizationId" uuid NOT NULL,
"UserId" uuid NULL,
"Email" character varying(256) NULL,
"Key" text NULL,
"ResetPasswordKey" text NULL,
"Status" smallint NOT NULL,
"Type" smallint NOT NULL,
"AccessAll" boolean NOT NULL,
"ExternalId" character varying(300) NULL,
"CreationDate" timestamp without time zone NOT NULL,
"RevisionDate" timestamp without time zone NOT NULL,
"Permissions" text NULL,
CONSTRAINT "PK_OrganizationUser" PRIMARY KEY ("Id"),
CONSTRAINT "FK_OrganizationUser_Organization_OrganizationId" FOREIGN KEY ("OrganizationId") REFERENCES "Organization" ("Id") ON DELETE CASCADE,
CONSTRAINT "FK_OrganizationUser_User_UserId" FOREIGN KEY ("UserId") REFERENCES "User" ("Id") ON DELETE RESTRICT
);
CREATE TABLE "ProviderUser" (
"Id" uuid NOT NULL,
"ProviderId" uuid NOT NULL,
"UserId" uuid NULL,
"Email" text NULL,
"Key" text NULL,
"Status" smallint NOT NULL,
"Type" smallint NOT NULL,
"Permissions" text NULL,
"CreationDate" timestamp without time zone NOT NULL,
"RevisionDate" timestamp without time zone NOT NULL,
CONSTRAINT "PK_ProviderUser" PRIMARY KEY ("Id"),
CONSTRAINT "FK_ProviderUser_Provider_ProviderId" FOREIGN KEY ("ProviderId") REFERENCES "Provider" ("Id") ON DELETE CASCADE,
CONSTRAINT "FK_ProviderUser_User_UserId" FOREIGN KEY ("UserId") REFERENCES "User" ("Id") ON DELETE RESTRICT
);
CREATE TABLE "Send" (
"Id" uuid NOT NULL,
"UserId" uuid NULL,
"OrganizationId" uuid NULL,
"Type" smallint NOT NULL,
"Data" text NULL,
"Key" text NULL,
"Password" character varying(300) NULL,
"MaxAccessCount" integer NULL,
"AccessCount" integer NOT NULL,
"CreationDate" timestamp without time zone NOT NULL,
"RevisionDate" timestamp without time zone NOT NULL,
"ExpirationDate" timestamp without time zone NULL,
"DeletionDate" timestamp without time zone NOT NULL,
"Disabled" boolean NOT NULL,
"HideEmail" boolean NULL,
CONSTRAINT "PK_Send" PRIMARY KEY ("Id"),
CONSTRAINT "FK_Send_Organization_OrganizationId" FOREIGN KEY ("OrganizationId") REFERENCES "Organization" ("Id") ON DELETE RESTRICT,
CONSTRAINT "FK_Send_User_UserId" FOREIGN KEY ("UserId") REFERENCES "User" ("Id") ON DELETE RESTRICT
);
CREATE TABLE "SsoUser" (
"Id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"UserId" uuid NOT NULL,
"OrganizationId" uuid NULL,
"ExternalId" character varying(50) COLLATE "postgresIndetermanisticCollation" NULL,
"CreationDate" timestamp without time zone NOT NULL,
CONSTRAINT "PK_SsoUser" PRIMARY KEY ("Id"),
CONSTRAINT "FK_SsoUser_Organization_OrganizationId" FOREIGN KEY ("OrganizationId") REFERENCES "Organization" ("Id") ON DELETE RESTRICT,
CONSTRAINT "FK_SsoUser_User_UserId" FOREIGN KEY ("UserId") REFERENCES "User" ("Id") ON DELETE CASCADE
);
CREATE TABLE "Transaction" (
"Id" uuid NOT NULL,
"UserId" uuid NULL,
"OrganizationId" uuid NULL,
"Type" smallint NOT NULL,
"Amount" numeric NOT NULL,
"Refunded" boolean NULL,
"RefundedAmount" numeric NULL,
"Details" character varying(100) NULL,
"PaymentMethodType" smallint NULL,
"Gateway" smallint NULL,
"GatewayId" character varying(50) NULL,
"CreationDate" timestamp without time zone NOT NULL,
CONSTRAINT "PK_Transaction" PRIMARY KEY ("Id"),
CONSTRAINT "FK_Transaction_Organization_OrganizationId" FOREIGN KEY ("OrganizationId") REFERENCES "Organization" ("Id") ON DELETE RESTRICT,
CONSTRAINT "FK_Transaction_User_UserId" FOREIGN KEY ("UserId") REFERENCES "User" ("Id") ON DELETE RESTRICT
);
CREATE TABLE "U2f" (
"Id" integer NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"UserId" uuid NOT NULL,
"KeyHandle" character varying(200) NULL,
"Challenge" character varying(200) NULL,
"AppId" character varying(50) NULL,
"Version" character varying(20) NULL,
"CreationDate" timestamp without time zone NOT NULL,
CONSTRAINT "PK_U2f" PRIMARY KEY ("Id"),
CONSTRAINT "FK_U2f_User_UserId" FOREIGN KEY ("UserId") REFERENCES "User" ("Id") ON DELETE CASCADE
);
CREATE TABLE "CollectionGroups" (
"CollectionId" uuid NOT NULL,
"GroupId" uuid NOT NULL,
"ReadOnly" boolean NOT NULL,
"HidePasswords" boolean NOT NULL,
CONSTRAINT "PK_CollectionGroups" PRIMARY KEY ("CollectionId", "GroupId"),
CONSTRAINT "FK_CollectionGroups_Collection_CollectionId" FOREIGN KEY ("CollectionId") REFERENCES "Collection" ("Id") ON DELETE CASCADE,
CONSTRAINT "FK_CollectionGroups_Group_GroupId" FOREIGN KEY ("GroupId") REFERENCES "Group" ("Id") ON DELETE CASCADE
);
CREATE TABLE "CollectionCipher" (
"CollectionId" uuid NOT NULL,
"CipherId" uuid NOT NULL,
CONSTRAINT "PK_CollectionCipher" PRIMARY KEY ("CollectionId", "CipherId"),
CONSTRAINT "FK_CollectionCipher_Cipher_CipherId" FOREIGN KEY ("CipherId") REFERENCES "Cipher" ("Id") ON DELETE CASCADE,
CONSTRAINT "FK_CollectionCipher_Collection_CollectionId" FOREIGN KEY ("CollectionId") REFERENCES "Collection" ("Id") ON DELETE CASCADE
);
CREATE TABLE "CollectionUsers" (
"CollectionId" uuid NOT NULL,
"OrganizationUserId" uuid NOT NULL,
"UserId" uuid NULL,
"ReadOnly" boolean NOT NULL,
"HidePasswords" boolean NOT NULL,
CONSTRAINT "PK_CollectionUsers" PRIMARY KEY ("CollectionId", "OrganizationUserId"),
CONSTRAINT "FK_CollectionUsers_Collection_CollectionId" FOREIGN KEY ("CollectionId") REFERENCES "Collection" ("Id") ON DELETE CASCADE,
CONSTRAINT "FK_CollectionUsers_OrganizationUser_OrganizationUserId" FOREIGN KEY ("OrganizationUserId") REFERENCES "OrganizationUser" ("Id") ON DELETE CASCADE,
CONSTRAINT "FK_CollectionUsers_User_UserId" FOREIGN KEY ("UserId") REFERENCES "User" ("Id") ON DELETE RESTRICT
);
CREATE TABLE "GroupUser" (
"GroupId" uuid NOT NULL,
"OrganizationUserId" uuid NOT NULL,
"UserId" uuid NULL,
CONSTRAINT "PK_GroupUser" PRIMARY KEY ("GroupId", "OrganizationUserId"),
CONSTRAINT "FK_GroupUser_Group_GroupId" FOREIGN KEY ("GroupId") REFERENCES "Group" ("Id") ON DELETE CASCADE,
CONSTRAINT "FK_GroupUser_OrganizationUser_OrganizationUserId" FOREIGN KEY ("OrganizationUserId") REFERENCES "OrganizationUser" ("Id") ON DELETE CASCADE,
CONSTRAINT "FK_GroupUser_User_UserId" FOREIGN KEY ("UserId") REFERENCES "User" ("Id") ON DELETE RESTRICT
);
CREATE TABLE "ProviderOrganizationProviderUser" (
"Id" uuid NOT NULL,
"ProviderOrganizationId" uuid NOT NULL,
"ProviderUserId" uuid NOT NULL,
"Type" smallint NOT NULL,
"Permissions" text NULL,
"CreationDate" timestamp without time zone NOT NULL,
"RevisionDate" timestamp without time zone NOT NULL,
CONSTRAINT "PK_ProviderOrganizationProviderUser" PRIMARY KEY ("Id"),
CONSTRAINT "FK_ProviderOrganizationProviderUser_ProviderOrganization_Provi~" FOREIGN KEY ("ProviderOrganizationId") REFERENCES "ProviderOrganization" ("Id") ON DELETE CASCADE,
CONSTRAINT "FK_ProviderOrganizationProviderUser_ProviderUser_ProviderUserId" FOREIGN KEY ("ProviderUserId") REFERENCES "ProviderUser" ("Id") ON DELETE CASCADE
);
CREATE INDEX "IX_Cipher_OrganizationId" ON "Cipher" ("OrganizationId");
CREATE INDEX "IX_Cipher_UserId" ON "Cipher" ("UserId");
CREATE INDEX "IX_Collection_OrganizationId" ON "Collection" ("OrganizationId");
CREATE INDEX "IX_CollectionCipher_CipherId" ON "CollectionCipher" ("CipherId");
CREATE INDEX "IX_CollectionGroups_GroupId" ON "CollectionGroups" ("GroupId");
CREATE INDEX "IX_CollectionUsers_OrganizationUserId" ON "CollectionUsers" ("OrganizationUserId");
CREATE INDEX "IX_CollectionUsers_UserId" ON "CollectionUsers" ("UserId");
CREATE INDEX "IX_Device_UserId" ON "Device" ("UserId");
CREATE INDEX "IX_EmergencyAccess_GranteeId" ON "EmergencyAccess" ("GranteeId");
CREATE INDEX "IX_EmergencyAccess_GrantorId" ON "EmergencyAccess" ("GrantorId");
CREATE INDEX "IX_Folder_UserId" ON "Folder" ("UserId");
CREATE INDEX "IX_Group_OrganizationId" ON "Group" ("OrganizationId");
CREATE INDEX "IX_GroupUser_OrganizationUserId" ON "GroupUser" ("OrganizationUserId");
CREATE INDEX "IX_GroupUser_UserId" ON "GroupUser" ("UserId");
CREATE INDEX "IX_OrganizationUser_OrganizationId" ON "OrganizationUser" ("OrganizationId");
CREATE INDEX "IX_OrganizationUser_UserId" ON "OrganizationUser" ("UserId");
CREATE INDEX "IX_Policy_OrganizationId" ON "Policy" ("OrganizationId");
CREATE INDEX "IX_ProviderOrganization_OrganizationId" ON "ProviderOrganization" ("OrganizationId");
CREATE INDEX "IX_ProviderOrganization_ProviderId" ON "ProviderOrganization" ("ProviderId");
CREATE INDEX "IX_ProviderOrganizationProviderUser_ProviderOrganizationId" ON "ProviderOrganizationProviderUser" ("ProviderOrganizationId");
CREATE INDEX "IX_ProviderOrganizationProviderUser_ProviderUserId" ON "ProviderOrganizationProviderUser" ("ProviderUserId");
CREATE INDEX "IX_ProviderUser_ProviderId" ON "ProviderUser" ("ProviderId");
CREATE INDEX "IX_ProviderUser_UserId" ON "ProviderUser" ("UserId");
CREATE INDEX "IX_Send_OrganizationId" ON "Send" ("OrganizationId");
CREATE INDEX "IX_Send_UserId" ON "Send" ("UserId");
CREATE INDEX "IX_SsoConfig_OrganizationId" ON "SsoConfig" ("OrganizationId");
CREATE INDEX "IX_SsoUser_OrganizationId" ON "SsoUser" ("OrganizationId");
CREATE INDEX "IX_SsoUser_UserId" ON "SsoUser" ("UserId");
CREATE INDEX "IX_Transaction_OrganizationId" ON "Transaction" ("OrganizationId");
CREATE INDEX "IX_Transaction_UserId" ON "Transaction" ("UserId");
CREATE INDEX "IX_U2f_UserId" ON "U2f" ("UserId");
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20210708191531_Init', '5.0.5');
COMMIT;

View File

@ -1,12 +0,0 @@
START TRANSACTION;
DROP TABLE "ProviderOrganizationProviderUser";
ALTER TABLE "Event" ADD "ProviderId" uuid NULL;
ALTER TABLE "Event" ADD "ProviderUserId" uuid NULL;
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20210709092227_RemoveProviderOrganizationProviderUser', '5.0.5');
COMMIT;

View File

@ -1,8 +0,0 @@
START TRANSACTION;
ALTER TABLE "User" ADD "ForcePasswordReset" boolean NOT NULL DEFAULT FALSE;
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20210716141748_UserForcePasswordReset', '5.0.5');
COMMIT;

View File

@ -1,12 +0,0 @@
START TRANSACTION;
ALTER TABLE "Organization" ADD "MaxAutoscaleSeats" integer NULL;
ALTER TABLE "Organization" ADD "OwnersNotifiedOfAutoscaling" timestamp without time zone NULL;
ALTER TABLE "Event" ADD "ProviderOrganizationId" uuid NULL;
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20210920201829_AddMaxAutoscaleSeatsToOrganization', '5.0.9');
COMMIT;

View File

@ -1,42 +0,0 @@
CREATE OR REPLACE FUNCTION updatePermissionsJson(permissions jsonb) returns jsonb LANGUAGE plpgsql AS $$
DECLARE manageAllCollections jsonb := COALESCE(jsonb_extract_path(permissions, 'manageAllCollections'), 'false');
DECLARE manageAssignedCollections jsonb := COALESCE(jsonb_extract_path(permissions, 'manageAssignedCollections'), 'false');
DECLARE createNewCollections jsonb := COALESCE(jsonb_extract_path(permissions, 'createNewCollections'), manageAllCollections);
DECLARE editAnyCollection jsonb := COALESCE(jsonb_extract_path(permissions, 'editAnyCollection'), manageAllCollections);
DECLARE deleteAnyCollection jsonb := COALESCE(jsonb_extract_path(permissions, 'deleteAnyCollection'), manageAllCollections);
DECLARE editAssignedCollections jsonb := COALESCE(jsonb_extract_path(permissions, 'editAssignedCollections'), manageAssignedCollections);
DECLARE deleteAssignedCollections jsonb := COALESCE(jsonb_extract_path(permissions, 'deleteAssignedCollections'), manageAssignedCollections);
BEGIN
RETURN
jsonb_set(
jsonb_set(
jsonb_set(
jsonb_set(
jsonb_set(
permissions,
'{createNewCollections}',
createNewCollections
),
'{editAnyCollection}',
editAnyCollection
),
'{deleteAnyCollection}',
deleteAnyCollection
),
'{editAssignedCollections}',
editAssignedCollections
),
'{deleteAssignedCollections}',
deleteAssignedCollections
);
END
$$;
UPDATE "OrganizationUser"
SET "Permissions" = updatePermissionsJson("Permissions"::jsonb)::text
WHERE "Permissions" IS NOT NULL;
DROP FUNCTION updatePermissionsJson(jsonb);

View File

@ -1,4 +0,0 @@
UPDATE "Organization"
SET "MaxAutoscaleSeats" = "Seats"
WHERE NOT EXISTS (SELECT 1 FROM "Organization" WHERE "MaxAutoscaleSeats" IS NOT NULL LIMIT 1)
AND NOT EXISTS (SELECT 1 FROM "Organization" WHERE "OwnersNotifiedOfAutoscaling" IS NOT NULL LIMIT 1)

View File

@ -1,33 +0,0 @@
START TRANSACTION;
ALTER TABLE "User" ADD "UsesCryptoAgent" boolean NOT NULL DEFAULT FALSE;
CREATE TABLE "OrganizationSponsorship" (
"Id" uuid NOT NULL,
"InstallationId" uuid NULL,
"SponsoringOrganizationId" uuid NULL,
"SponsoringOrganizationUserId" uuid NULL,
"SponsoredOrganizationId" uuid NULL,
"FriendlyName" character varying(256) NULL,
"OfferedToEmail" character varying(256) NULL,
"PlanSponsorshipType" smallint NULL,
"CloudSponsor" boolean NOT NULL,
"LastSyncDate" timestamp without time zone NULL,
"TimesRenewedWithoutValidation" smallint NOT NULL,
"SponsorshipLapsedDate" timestamp without time zone NULL,
CONSTRAINT "PK_OrganizationSponsorship" PRIMARY KEY ("Id"),
CONSTRAINT "FK_OrganizationSponsorship_Installation_InstallationId" FOREIGN KEY ("InstallationId") REFERENCES "Installation" ("Id") ON DELETE RESTRICT,
CONSTRAINT "FK_OrganizationSponsorship_Organization_SponsoredOrganizationId" FOREIGN KEY ("SponsoredOrganizationId") REFERENCES "Organization" ("Id") ON DELETE RESTRICT,
CONSTRAINT "FK_OrganizationSponsorship_Organization_SponsoringOrganization~" FOREIGN KEY ("SponsoringOrganizationId") REFERENCES "Organization" ("Id") ON DELETE RESTRICT
);
CREATE INDEX "IX_OrganizationSponsorship_InstallationId" ON "OrganizationSponsorship" ("InstallationId");
CREATE INDEX "IX_OrganizationSponsorship_SponsoredOrganizationId" ON "OrganizationSponsorship" ("SponsoredOrganizationId");
CREATE INDEX "IX_OrganizationSponsorship_SponsoringOrganizationId" ON "OrganizationSponsorship" ("SponsoringOrganizationId");
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20211108225011_OrganizationSponsorship', '5.0.9');
COMMIT;

View File

@ -1,9 +0,0 @@
START TRANSACTION;
ALTER TABLE "User" ADD "UsesKeyConnector" boolean NOT NULL DEFAULT FALSE;
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20211108041547_KeyConnector', '5.0.9');
COMMIT;

View File

@ -1,10 +0,0 @@
START TRANSACTION;
ALTER TABLE "User" ADD "FailedLoginCount" integer NOT NULL DEFAULT 0;
ALTER TABLE "User" ADD "LastFailedLoginDate" timestamp without time zone NULL;
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20220301211818_FailedLoginCaptcha', '5.0.12');
COMMIT;

View File

@ -1,59 +0,0 @@
START TRANSACTION;
ALTER TABLE "OrganizationSponsorship" DROP CONSTRAINT "FK_OrganizationSponsorship_Installation_InstallationId";
DROP INDEX "IX_OrganizationSponsorship_InstallationId";
ALTER TABLE "OrganizationSponsorship" DROP COLUMN "InstallationId";
ALTER TABLE "OrganizationSponsorship" DROP COLUMN "TimesRenewedWithoutValidation";
CREATE TABLE "OrganizationApiKey" (
"Id" uuid NOT NULL,
"OrganizationId" uuid NOT NULL,
"Type" smallint NOT NULL,
"ApiKey" character varying(30) NULL,
"RevisionDate" timestamp without time zone NOT NULL,
CONSTRAINT "PK_OrganizationApiKey" PRIMARY KEY ("Id"),
CONSTRAINT "FK_OrganizationApiKey_Organization_OrganizationId" FOREIGN KEY ("OrganizationId") REFERENCES "Organization" ("Id") ON DELETE CASCADE
);
INSERT INTO "OrganizationApiKey"(
"Id",
"OrganizationId",
"ApiKey",
"Type",
"RevisionDate")
SELECT uuid_in(overlay(overlay(md5(random()::text || ':' || random()::text) placing '4' from 13) placing to_hex(floor(random()*(11-8+1) + 8)::int)::text from 17)::cstring),
"Id" AS "OrganizationId",
"ApiKey",
0 AS "Type",
"RevisionDate"
FROM "Organization";
ALTER TABLE "Organization" DROP COLUMN "ApiKey";
ALTER TABLE "OrganizationSponsorship" RENAME COLUMN "SponsorshipLapsedDate" TO "ValidUntil";
ALTER TABLE "OrganizationSponsorship" RENAME COLUMN "CloudSponsor" TO "ToDelete";
CREATE TABLE "OrganizationConnection" (
"Id" uuid NOT NULL,
"Type" smallint NOT NULL,
"OrganizationId" uuid NOT NULL,
"Enabled" boolean NOT NULL,
"Config" text NULL,
CONSTRAINT "PK_OrganizationConnection" PRIMARY KEY ("Id"),
CONSTRAINT "FK_OrganizationConnection_Organization_OrganizationId" FOREIGN KEY ("OrganizationId") REFERENCES "Organization" ("Id") ON DELETE CASCADE
);
CREATE INDEX "IX_OrganizationApiKey_OrganizationId" ON "OrganizationApiKey" ("OrganizationId");
CREATE INDEX "IX_OrganizationConnection_OrganizationId" ON "OrganizationConnection" ("OrganizationId");
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20220322183505_SelfHostF4E', '5.0.12');
COMMIT;

View File

@ -1,16 +0,0 @@
START TRANSACTION;
ALTER TABLE "OrganizationSponsorship" DROP CONSTRAINT "FK_OrganizationSponsorship_Organization_SponsoringOrganization~";
ALTER TABLE "OrganizationSponsorship" ALTER COLUMN "SponsoringOrganizationUserId" SET NOT NULL;
ALTER TABLE "OrganizationSponsorship" ALTER COLUMN "SponsoringOrganizationUserId" SET DEFAULT '00000000-0000-0000-0000-000000000000';
ALTER TABLE "OrganizationSponsorship" ALTER COLUMN "SponsoringOrganizationId" SET NOT NULL;
ALTER TABLE "OrganizationSponsorship" ALTER COLUMN "SponsoringOrganizationId" SET DEFAULT '00000000-0000-0000-0000-000000000000';
ALTER TABLE "OrganizationSponsorship" ADD CONSTRAINT "FK_OrganizationSponsorship_Organization_SponsoringOrganization~" FOREIGN KEY ("SponsoringOrganizationId") REFERENCES "Organization" ("Id") ON DELETE CASCADE;
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20220411190525_SponsorshipBulkActions', '5.0.12');
COMMIT;

View File

@ -1,14 +0,0 @@
START TRANSACTION;
ALTER TABLE "OrganizationSponsorship" DROP CONSTRAINT "FK_OrganizationSponsorship_Organization_SponsoringOrganization~";
ALTER TABLE "OrganizationSponsorship" ALTER COLUMN "SponsoringOrganizationId" DROP NOT NULL;
ALTER TABLE "Event" ADD "InstallationId" uuid NULL;
ALTER TABLE "OrganizationSponsorship" ADD CONSTRAINT "FK_OrganizationSponsorship_Organization_SponsoringOrganization~" FOREIGN KEY ("SponsoringOrganizationId") REFERENCES "Organization" ("Id") ON DELETE RESTRICT;
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20220420171153_AddInstallationIdToEvents', '5.0.12');
COMMIT;

View File

@ -1,8 +0,0 @@
START TRANSACTION;
ALTER TABLE "User" ADD "UnknownDeviceVerificationEnabled" boolean NOT NULL DEFAULT true;
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20220524170740_DeviceUnknownVerification', '5.0.12');
COMMIT;

View File

@ -1,8 +0,0 @@
START TRANSACTION;
ALTER TABLE "Organization" ADD "UseScim" boolean NOT NULL DEFAULT FALSE;
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20220707162231_UseScimFlag', '6.0.4');
COMMIT;

View File

@ -1,133 +0,0 @@
START TRANSACTION;
ALTER TABLE "User" ALTER COLUMN "RevisionDate" TYPE timestamp with time zone;
ALTER TABLE "User" ALTER COLUMN "RenewalReminderDate" TYPE timestamp with time zone;
ALTER TABLE "User" ALTER COLUMN "PremiumExpirationDate" TYPE timestamp with time zone;
ALTER TABLE "User" ALTER COLUMN "LastFailedLoginDate" TYPE timestamp with time zone;
ALTER TABLE "User" ALTER COLUMN "CreationDate" TYPE timestamp with time zone;
ALTER TABLE "User" ALTER COLUMN "AccountRevisionDate" TYPE timestamp with time zone;
ALTER TABLE "Transaction" ALTER COLUMN "CreationDate" TYPE timestamp with time zone;
ALTER TABLE "SsoUser" ALTER COLUMN "CreationDate" TYPE timestamp with time zone;
ALTER TABLE "SsoConfig" ALTER COLUMN "RevisionDate" TYPE timestamp with time zone;
ALTER TABLE "SsoConfig" ALTER COLUMN "CreationDate" TYPE timestamp with time zone;
ALTER TABLE "Send" ALTER COLUMN "RevisionDate" TYPE timestamp with time zone;
ALTER TABLE "Send" ALTER COLUMN "ExpirationDate" TYPE timestamp with time zone;
ALTER TABLE "Send" ALTER COLUMN "DeletionDate" TYPE timestamp with time zone;
ALTER TABLE "Send" ALTER COLUMN "CreationDate" TYPE timestamp with time zone;
ALTER TABLE "ProviderUser" ALTER COLUMN "RevisionDate" TYPE timestamp with time zone;
ALTER TABLE "ProviderUser" ALTER COLUMN "CreationDate" TYPE timestamp with time zone;
ALTER TABLE "ProviderOrganization" ALTER COLUMN "RevisionDate" TYPE timestamp with time zone;
ALTER TABLE "ProviderOrganization" ALTER COLUMN "CreationDate" TYPE timestamp with time zone;
ALTER TABLE "Provider" ALTER COLUMN "RevisionDate" TYPE timestamp with time zone;
ALTER TABLE "Provider" ALTER COLUMN "CreationDate" TYPE timestamp with time zone;
ALTER TABLE "Policy" ALTER COLUMN "RevisionDate" TYPE timestamp with time zone;
ALTER TABLE "Policy" ALTER COLUMN "CreationDate" TYPE timestamp with time zone;
ALTER TABLE "OrganizationUser" ALTER COLUMN "RevisionDate" TYPE timestamp with time zone;
ALTER TABLE "OrganizationUser" ALTER COLUMN "CreationDate" TYPE timestamp with time zone;
ALTER TABLE "OrganizationSponsorship" ALTER COLUMN "ValidUntil" TYPE timestamp with time zone;
ALTER TABLE "OrganizationSponsorship" ALTER COLUMN "LastSyncDate" TYPE timestamp with time zone;
ALTER TABLE "OrganizationApiKey" ALTER COLUMN "RevisionDate" TYPE timestamp with time zone;
ALTER TABLE "Organization" ALTER COLUMN "RevisionDate" TYPE timestamp with time zone;
ALTER TABLE "Organization" ALTER COLUMN "OwnersNotifiedOfAutoscaling" TYPE timestamp with time zone;
ALTER TABLE "Organization" ALTER COLUMN "ExpirationDate" TYPE timestamp with time zone;
ALTER TABLE "Organization" ALTER COLUMN "CreationDate" TYPE timestamp with time zone;
ALTER TABLE "Installation" ALTER COLUMN "CreationDate" TYPE timestamp with time zone;
ALTER TABLE "Group" ALTER COLUMN "RevisionDate" TYPE timestamp with time zone;
ALTER TABLE "Group" ALTER COLUMN "CreationDate" TYPE timestamp with time zone;
ALTER TABLE "Grant" ALTER COLUMN "ExpirationDate" TYPE timestamp with time zone;
ALTER TABLE "Grant" ALTER COLUMN "CreationDate" TYPE timestamp with time zone;
ALTER TABLE "Grant" ALTER COLUMN "ConsumedDate" TYPE timestamp with time zone;
ALTER TABLE "Folder" ALTER COLUMN "RevisionDate" TYPE timestamp with time zone;
ALTER TABLE "Folder" ALTER COLUMN "CreationDate" TYPE timestamp with time zone;
ALTER TABLE "Event" ALTER COLUMN "Date" TYPE timestamp with time zone;
ALTER TABLE "EmergencyAccess" ALTER COLUMN "RevisionDate" TYPE timestamp with time zone;
ALTER TABLE "EmergencyAccess" ALTER COLUMN "RecoveryInitiatedDate" TYPE timestamp with time zone;
ALTER TABLE "EmergencyAccess" ALTER COLUMN "LastNotificationDate" TYPE timestamp with time zone;
ALTER TABLE "EmergencyAccess" ALTER COLUMN "CreationDate" TYPE timestamp with time zone;
ALTER TABLE "Device" ALTER COLUMN "RevisionDate" TYPE timestamp with time zone;
ALTER TABLE "Device" ALTER COLUMN "CreationDate" TYPE timestamp with time zone;
ALTER TABLE "Collection" ALTER COLUMN "RevisionDate" TYPE timestamp with time zone;
ALTER TABLE "Collection" ALTER COLUMN "CreationDate" TYPE timestamp with time zone;
ALTER TABLE "Cipher" ALTER COLUMN "RevisionDate" TYPE timestamp with time zone;
ALTER TABLE "Cipher" ALTER COLUMN "DeletedDate" TYPE timestamp with time zone;
ALTER TABLE "Cipher" ALTER COLUMN "CreationDate" TYPE timestamp with time zone;
CREATE TABLE "AuthRequest" (
"Id" uuid NOT NULL,
"UserId" uuid NOT NULL,
"Type" smallint NOT NULL,
"RequestDeviceIdentifier" text NULL,
"RequestDeviceType" smallint NOT NULL,
"RequestIpAddress" text NULL,
"RequestFingerprint" text NULL,
"ResponseDeviceId" uuid NULL,
"AccessCode" text NULL,
"PublicKey" text NULL,
"Key" text NULL,
"MasterPasswordHash" text NULL,
"CreationDate" timestamp with time zone NOT NULL,
"ResponseDate" timestamp with time zone NULL,
"AuthenticationDate" timestamp with time zone NULL,
CONSTRAINT "PK_AuthRequest" PRIMARY KEY ("Id"),
CONSTRAINT "FK_AuthRequest_Device_ResponseDeviceId" FOREIGN KEY ("ResponseDeviceId") REFERENCES "Device" ("Id"),
CONSTRAINT "FK_AuthRequest_User_UserId" FOREIGN KEY ("UserId") REFERENCES "User" ("Id") ON DELETE CASCADE
);
CREATE INDEX "IX_AuthRequest_ResponseDeviceId" ON "AuthRequest" ("ResponseDeviceId");
CREATE INDEX "IX_AuthRequest_UserId" ON "AuthRequest" ("UserId");
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20220830163921_PasswordlessAuthRequests', '6.0.4');
COMMIT;

View File

@ -1,8 +0,0 @@
START TRANSACTION;
ALTER TABLE "Event" ADD "SystemUser" smallint NULL;
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20220927142152_EventsSystemUser', '6.0.4');
COMMIT;

View File

@ -1,8 +0,0 @@
START TRANSACTION;
ALTER TABLE "Organization" ADD "UseCustomPermissions" boolean NOT NULL DEFAULT FALSE;
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20221116102326_UseCustomPermissionsFlag', '6.0.4');
COMMIT;

View File

@ -1,8 +0,0 @@
START TRANSACTION;
ALTER TABLE "AuthRequest" ADD "Approved" boolean NULL;
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20221025033204_PasswordlessAuthRequestAddApprovedColumn', '6.0.4');
COMMIT;

View File

@ -1,9 +0,0 @@
START TRANSACTION;
ALTER TABLE "User" ADD "AvatarColor" character varying(7) NULL;
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20221115034053_AvatarColor', '6.0.4');
COMMIT;