From d245bdf337bdd51b1df107d82f5f05666f9973b2 Mon Sep 17 00:00:00 2001 From: Robson Paproski Date: Sun, 27 Dec 2015 10:16:41 -0200 Subject: [PATCH] SQL Fields Updated --- .../PostgreSQLIdentity.sql | 85 ++++++++++++++----- 1 file changed, 63 insertions(+), 22 deletions(-) diff --git a/src/AspNetIdentity3PostgreSQL/PostgreSQLIdentity.sql b/src/AspNetIdentity3PostgreSQL/PostgreSQLIdentity.sql index c967af7..d602fd0 100644 --- a/src/AspNetIdentity3PostgreSQL/PostgreSQLIdentity.sql +++ b/src/AspNetIdentity3PostgreSQL/PostgreSQLIdentity.sql @@ -1,40 +1,58 @@ - CREATE TABLE "AspNetRoles" ( - "Id" varchar(128) NOT NULL, +CREATE TABLE public."AspNetRoles" ( + "Id" VARCHAR(128) NOT NULL, "Name" TEXT NOT NULL, - PRIMARY KEY ("Id") -); + "ConcurrencyStamp" TEXT, + CONSTRAINT "AspNetRoles_pkey" PRIMARY KEY("Id") +) +WITH (oids = false); -CREATE TABLE "AspNetUsers" ( +CREATE TABLE public."AspNetUsers" ( "Id" UUID NOT NULL, "UserName" TEXT NOT NULL, "PasswordHash" TEXT, "SecurityStamp" TEXT, - "Email" TEXT DEFAULT NULL, - "EmailConfirmed" boolean NOT NULL DEFAULT false, + "Email" TEXT, + "EmailConfirmed" BOOLEAN DEFAULT false NOT NULL, "PhoneNumber" TEXT, - "PhoneNumberConfirmed" boolean NOT NULL DEFAULT false, - "TwoFactorEnabled" boolean NOT NULL DEFAULT false, - "LockoutEndDateUtc" timestamptz NULL, - "LockoutEnabled" boolean NOT NULL DEFAULT false, - "AccessFailedCount" INT NOT NULL, - PRIMARY KEY ("Id") -); + "PhoneNumberConfirmed" BOOLEAN DEFAULT false NOT NULL, + "TwoFactorEnabled" BOOLEAN DEFAULT false NOT NULL, + "LockoutEndDateUtc" TIMESTAMP WITH TIME ZONE, + "LockoutEnabled" BOOLEAN DEFAULT false NOT NULL, + "AccessFailedCount" INTEGER NOT NULL, + "ConcurrencyStamp" TEXT, + CONSTRAINT "AspNetUsers_pkey" PRIMARY KEY("Id") +) +WITH (oids = false); -CREATE TABLE "AspNetUserClaims" ( +CREATE TABLE public."AspNetUserClaims" ( "Id" SERIAL, - "ClaimType" TEXT NULL, - "ClaimValue" TEXT NULL, + "ClaimType" TEXT, + "ClaimValue" TEXT, "UserId" UUID NOT NULL, - PRIMARY KEY ("Id") -); + CONSTRAINT "AspNetUserClaims_pkey" PRIMARY KEY("Id"), + CONSTRAINT "FK_AspNetUserClaims_AspNetUsers_User_Id" FOREIGN KEY ("UserId") + REFERENCES public."AspNetUsers"("Id") + ON DELETE CASCADE + ON UPDATE NO ACTION + NOT DEFERRABLE +) +WITH (oids = false); -CREATE TABLE "AspNetUserLogins" ( + +CREATE TABLE public."AspNetUserLogins" ( "UserId" UUID NOT NULL, "LoginProvider" TEXT NOT NULL, "ProviderKey" TEXT NOT NULL, - PRIMARY KEY ("UserId", "LoginProvider", "ProviderKey") -); + "ProviderDisplayName" TEXT, + CONSTRAINT "AspNetUserLogins_pkey" PRIMARY KEY("UserId", "LoginProvider", "ProviderKey"), + CONSTRAINT "FK_AspNetUserLogins_AspNetUsers_UserId" FOREIGN KEY ("UserId") + REFERENCES public."AspNetUsers"("Id") + ON DELETE CASCADE + ON UPDATE NO ACTION + NOT DEFERRABLE +) +WITH (oids = false); CREATE TABLE "AspNetUserRoles" ( "UserId" UUID NOT NULL, @@ -42,6 +60,29 @@ CREATE TABLE "AspNetUserRoles" ( PRIMARY KEY ("UserId", "RoleId") ); +CREATE TABLE public."AspNetUserRoles" ( + "UserId" UUID NOT NULL, + "RoleId" VARCHAR(128) NOT NULL, + CONSTRAINT "AspNetUserRoles_pkey" PRIMARY KEY("UserId", "RoleId"), + CONSTRAINT "FK_AspNetUserRoles_AspNetRoles_RoleId" FOREIGN KEY ("RoleId") + REFERENCES public."AspNetRoles"("Id") + ON DELETE CASCADE + ON UPDATE NO ACTION + NOT DEFERRABLE, + CONSTRAINT "FK_AspNetUserRoles_AspNetUsers_UserId" FOREIGN KEY ("UserId") + REFERENCES public."AspNetUsers"("Id") + ON DELETE CASCADE + ON UPDATE NO ACTION + NOT DEFERRABLE +) +WITH (oids = false); + +CREATE INDEX "IX_AspNetUserRoles_RoleId" ON public."AspNetUserRoles" + USING btree ("RoleId" COLLATE pg_catalog."default"); + +CREATE INDEX "IX_AspNetUserRoles_UserId" ON public."AspNetUserRoles" + USING btree ("UserId"); + CREATE INDEX "IX_AspNetUserClaims_UserId" ON "AspNetUserClaims" ("UserId"); CREATE INDEX "IX_AspNetUserLogins_UserId" ON "AspNetUserLogins" ("UserId"); CREATE INDEX "IX_AspNetUserRoles_RoleId" ON "AspNetUserRoles" ("RoleId");