forked from Explore-AI/SmartSystems-FastAPI-Example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIdentityTables_init.sql
More file actions
28 lines (24 loc) · 969 Bytes
/
Copy pathIdentityTables_init.sql
File metadata and controls
28 lines (24 loc) · 969 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
--####################################################################################################
-- This script is intended for local development only.
-- Creates initial tables [users,roles,userRoles] for 'Identity_DB'
-- V1, 2023-04-19, Qiniso Mazibuko, Initial Version
--####################################################################################################
USE Identity_DB;
CREATE TABLE IdentityUser (
Id INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
UserName NVARCHAR(50) NOT NULL UNIQUE,
Email NVARCHAR(320) NOT NULL UNIQUE,
PasswordHash NVARCHAR(256) NOT NULL,
PasswordSalt NVARCHAR(256) NOT NULL
);
CREATE TABLE IdentityRole (
Id INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
Name NVARCHAR(50) NOT NULL UNIQUE
);
CREATE TABLE UserRoles (
UserId INT NOT NULL,
RoleId INT NOT NULL,
PRIMARY KEY (UserId, RoleId),
FOREIGN KEY (UserId) REFERENCES Users (Id),
FOREIGN KEY (RoleId) REFERENCES Roles (Id)
);