mirror of
https://github.com/bitwarden/server.git
synced 2024-12-28 17:57:37 +01:00
60 lines
2.1 KiB
Plaintext
60 lines
2.1 KiB
Plaintext
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;
|
|
|