1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-03 17:12:49 -05:00

Initial db work (#1687)

* Add organization sponsorship databases to all providers

* Generalize create and update for database, specialize in code
This commit is contained in:
Matt Gibson
2021-11-04 10:46:49 -05:00
committed by GitHub
parent ee46a6d63b
commit 079adc60b6
26 changed files with 4276 additions and 3 deletions

View File

@ -0,0 +1,31 @@
START TRANSACTION;
ALTER TABLE "User" ADD "UsesCryptoAgent" boolean NOT NULL DEFAULT FALSE;
CREATE TABLE "OrganizationSponsorship" (
"Id" uuid NOT NULL,
"InstallationId" uuid NULL,
"SponsoringOrganizationId" uuid NOT NULL,
"SponsoringOrganizationUserId" uuid NOT NULL,
"SponsoredOrganizationId" uuid NULL,
"OfferedToEmail" character varying(256) 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 CASCADE
);
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 ('20211102205745_OrganizationSponsorship', '5.0.9');
COMMIT;