-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreateDb.sql
163 lines (153 loc) · 4.43 KB
/
CreateDb.sql
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
drop database IglandMVCdb;
create database if not exists IglandMVCdb;
use IglandMVCdb;
create table if not EXISTS AspNetUsers
(
Id varchar(255) not null unique,
UserName varchar(255),
NormalizedUserName varchar(255),
Email varchar(255),
NormalizedEmail varchar(255),
EmailConfirmed bit not null,
PasswordHash varchar(255),
SecurityStamp varchar(255),
ConcurrencyStamp varchar(255),
PhoneNumber varchar(50),
PhoneNumberConfirmed bit not null,
TwoFactorEnabled bit not null,
LockoutEnd TIMESTAMP,
LockoutEnabled bit not null,
AccessFailedCount int not null,
CONSTRAINT PK_AspNetUsers PRIMARY KEY (Id)
);
create table if not EXISTS AspNetRoles
(
Id varchar(255) not null,
Name varchar(255),
NormalizedName varchar(255),
ConcurrencyStamp varchar(255),
CONSTRAINT U_ROLE_ID_PK PRIMARY KEY (Id)
);
insert into AspNetRoles(id, Name, NormalizedName) values('Administrator', 'Administrator', 'Administrator');
create table if not EXISTS AspNetUserTokens
(
UserId varchar(255) not null,
LoginProvider varchar(255) not null ,
Name varchar(255) not null,
Value varchar(255),
CONSTRAINT PK_AspNetUserTokens PRIMARY KEY (UserId, LoginProvider)
);
create table if not EXISTS AspNetRoleClaims
(
Id int UNIQUE auto_increment,
ClaimType varchar(255) not null ,
ClaimValue varchar(255) not null,
RoleId varchar(255),
CONSTRAINT PK_AspNetRoleClaims PRIMARY KEY (Id),
foreign key(RoleId)
references AspNetRoles(Id)
);
create table if not EXISTS AspNetUserClaims
(
Id int UNIQUE auto_increment,
ClaimType varchar(255),
ClaimValue varchar(255),
UserId varchar(255),
CONSTRAINT PK_AspNetRoleClaims PRIMARY KEY (Id),
foreign key(UserId)
references AspNetUsers(Id)
);
create table if not EXISTS AspNetUserLogins
(
LoginProvider int UNIQUE auto_increment,
ProviderKey varchar(255) not null ,
ProviderDisplayName varchar(255) not null,
UserId varchar(255) not null,
CONSTRAINT PK_AspNetUserLogins PRIMARY KEY (LoginProvider),
foreign key(UserId)
references AspNetUsers(Id)
);
create table if not EXISTS AspNetUserRoles
(
UserId varchar(255) not null,
RoleId varchar(255) not null,
CONSTRAINT PK_AspNetUserRoles PRIMARY KEY (UserId,RoleId),
foreign key(UserId)
references AspNetUsers(Id),
foreign key(RoleId)
references AspNetRoles(Id)
);
create table if not EXISTS Kunder
(
KundeID int PRIMARY KEY auto_increment,
KundeNavn varchar(100)
);
create table if not EXISTS Ordre
(
OrdreNummer int PRIMARY KEY,
KundeID int,
SerieNummer varchar(30),
VareNavn varchar(30),
Status varchar(30),
FOREIGN KEY (KundeId)
REFERENCES Kunder (KundeId)
);
create table if not EXISTS ServiceDokument
(
ServiceSkjemaID int PRIMARY KEY auto_increment,
OrdreNummer int,
Aarsmodel int,
Garanti varchar(255),
Reparasjonsbeskrivelse varchar(255),
MedgaatteDeler varchar(255),
DeleRetur varchar(255),
ForesendelsesMaate varchar(255),
foreign key(OrdreNummer) references Ordre(OrdreNummer)
);
create table if not EXISTS ArbDok
(
ArbDokID int PRIMARY KEY auto_increment,
OrdreNummer int,
Uke varchar(2),
HenvendelseMotatt DATE,
AvtaltLevering DATE,
ProduktMotatt DATE,
SjekkUtfort DATE,
AvtaltFerdig DATE,
ServiceFerdig DATE,
AntallTimer int,
BestillingFraKunde varchar(255),
NotatFraMekaniker varchar(255),
foreign key(OrdreNummer)
references Ordre(OrdreNummer)
);
CREATE TABLE IF NOT EXISTS Sjekkliste
(
SjekklisteID int PRIMARY KEY AUTO_INCREMENT,
OrdreNummer int,
MekanikerKommentar varchar(255),
MekanikerNavn varchar(100),
Dato date,
SerieNummer varchar(255),
AntallTimer decimal,
StatusString varchar(255),
FOREIGN KEY(OrdreNummer) REFERENCES Ordre(OrdreNummer)
);
create table if not EXISTS KoblingsTabell
(
OrdreNummer int,
Avdeling varchar(255),
KoblingsTabellID int PRIMARY KEY,
TidsbrukPerAvdeling varchar(255),
foreign key(OrdreNummer)
references Ordre(OrdreNummer)
);
create table if not EXISTS Avdeling
(
Rolle varchar(255) PRIMARY KEY,
KoblingsTabellID int,
AvdelingsID int,
foreign key(KoblingsTabellID)
references KoblingsTabell(KoblingsTabellID)
);
SHOW TABLES;