|
@@ -1,48 +1,48 @@
|
1
|
|
-IF (OBJECT_ID('FK_kunsthåndværk_users', 'F') IS NOT NULL)
|
|
1
|
+IF (OBJECT_ID('kunsthåndværk_user_id_fkey', 'F') IS NOT NULL)
|
2
|
2
|
BEGIN
|
3
|
|
-ALTER TABLE [kunsthåndværk] DROP CONSTRAINT [FK_kunsthåndværk_users]
|
|
3
|
+ALTER TABLE [kunsthåndværk] DROP CONSTRAINT [kunsthåndværk_user_id_fkey]
|
4
|
4
|
END
|
5
|
5
|
GO
|
6
|
6
|
|
7
|
|
-IF (OBJECT_ID('FK_barcodes_products', 'F') IS NOT NULL)
|
|
7
|
+IF (OBJECT_ID('barcodes_product_id_fkey', 'F') IS NOT NULL)
|
8
|
8
|
BEGIN
|
9
|
|
-ALTER TABLE [barcodes] DROP CONSTRAINT [FK_barcodes_products]
|
|
9
|
+ALTER TABLE [barcodes] DROP CONSTRAINT [barcodes_product_id_fkey]
|
10
|
10
|
END
|
11
|
11
|
GO
|
12
|
12
|
|
13
|
|
-IF (OBJECT_ID('FK_posts_users', 'F') IS NOT NULL)
|
|
13
|
+IF (OBJECT_ID('posts_user_id_fkey', 'F') IS NOT NULL)
|
14
|
14
|
BEGIN
|
15
|
|
-ALTER TABLE [posts] DROP CONSTRAINT [FK_posts_users]
|
|
15
|
+ALTER TABLE [posts] DROP CONSTRAINT [posts_user_id_fkey]
|
16
|
16
|
END
|
17
|
17
|
GO
|
18
|
18
|
|
19
|
|
-IF (OBJECT_ID('FK_posts_categories', 'F') IS NOT NULL)
|
|
19
|
+IF (OBJECT_ID('posts_category_id_fkey', 'F') IS NOT NULL)
|
20
|
20
|
BEGIN
|
21
|
|
-ALTER TABLE [posts] DROP CONSTRAINT [FK_posts_categories]
|
|
21
|
+ALTER TABLE [posts] DROP CONSTRAINT [posts_category_id_fkey]
|
22
|
22
|
END
|
23
|
23
|
GO
|
24
|
24
|
|
25
|
|
-IF (OBJECT_ID('FK_post_tags_tags', 'F') IS NOT NULL)
|
|
25
|
+IF (OBJECT_ID('post_tags_tag_id_fkey', 'F') IS NOT NULL)
|
26
|
26
|
BEGIN
|
27
|
|
-ALTER TABLE [post_tags] DROP CONSTRAINT [FK_post_tags_tags]
|
|
27
|
+ALTER TABLE [post_tags] DROP CONSTRAINT [post_tags_tag_id_fkey]
|
28
|
28
|
END
|
29
|
29
|
GO
|
30
|
30
|
|
31
|
|
-IF (OBJECT_ID('FK_post_tags_posts', 'F') IS NOT NULL)
|
|
31
|
+IF (OBJECT_ID('post_tags_post_id_fkey', 'F') IS NOT NULL)
|
32
|
32
|
BEGIN
|
33
|
|
-ALTER TABLE [post_tags] DROP CONSTRAINT [FK_post_tags_posts]
|
|
33
|
+ALTER TABLE [post_tags] DROP CONSTRAINT [post_tags_post_id_fkey]
|
34
|
34
|
END
|
35
|
35
|
GO
|
36
|
36
|
|
37
|
|
-IF (OBJECT_ID('FK_comments_posts', 'F') IS NOT NULL)
|
|
37
|
+IF (OBJECT_ID('comments_post_id_fkey', 'F') IS NOT NULL)
|
38
|
38
|
BEGIN
|
39
|
|
-ALTER TABLE [comments] DROP CONSTRAINT [FK_comments_posts]
|
|
39
|
+ALTER TABLE [comments] DROP CONSTRAINT [comments_post_id_fkey]
|
40
|
40
|
END
|
41
|
41
|
GO
|
42
|
42
|
|
43
|
|
-IF (OBJECT_ID('FK_comments_categories', 'F') IS NOT NULL)
|
|
43
|
+IF (OBJECT_ID('comments_category_id_fkey', 'F') IS NOT NULL)
|
44
|
44
|
BEGIN
|
45
|
|
-ALTER TABLE [comments] DROP CONSTRAINT [FK_comments_categories]
|
|
45
|
+ALTER TABLE [comments] DROP CONSTRAINT [comments_category_id_fkey]
|
46
|
46
|
END
|
47
|
47
|
GO
|
48
|
48
|
|
|
@@ -136,74 +136,111 @@ DROP TABLE [nopk]
|
136
|
136
|
END
|
137
|
137
|
GO
|
138
|
138
|
|
|
139
|
+DROP SEQUENCE IF EXISTS [categories_id_seq]
|
|
140
|
+GO
|
|
141
|
+CREATE SEQUENCE [categories_id_seq] AS int START WITH 1 INCREMENT BY 1 NO CACHE
|
|
142
|
+GO
|
|
143
|
+
|
139
|
144
|
CREATE TABLE [categories](
|
140
|
|
- [id] [int] IDENTITY,
|
|
145
|
+ [id] [int] NOT NULL CONSTRAINT [categories_id_def] DEFAULT NEXT VALUE FOR [categories_id_seq],
|
141
|
146
|
[name] [nvarchar](255) NOT NULL,
|
142
|
147
|
[icon] [image],
|
143
|
|
- PRIMARY KEY CLUSTERED([id] ASC)
|
|
148
|
+ CONSTRAINT [categories_pkey] PRIMARY KEY CLUSTERED([id] ASC)
|
144
|
149
|
)
|
145
|
150
|
GO
|
146
|
151
|
|
|
152
|
+DROP SEQUENCE IF EXISTS [comments_id_seq]
|
|
153
|
+GO
|
|
154
|
+CREATE SEQUENCE [comments_id_seq] AS bigint START WITH 1 INCREMENT BY 1 NO CACHE
|
|
155
|
+GO
|
|
156
|
+
|
147
|
157
|
CREATE TABLE [comments](
|
148
|
|
- [id] [bigint] IDENTITY,
|
|
158
|
+ [id] [bigint] NOT NULL CONSTRAINT [comments_id_def] DEFAULT NEXT VALUE FOR [comments_id_seq],
|
149
|
159
|
[post_id] [int] NOT NULL,
|
150
|
160
|
[message] [nvarchar](255) NOT NULL,
|
151
|
161
|
[category_id] [int] NOT NULL,
|
152
|
|
- PRIMARY KEY CLUSTERED([id] ASC)
|
|
162
|
+ CONSTRAINT [comments_pkey] PRIMARY KEY CLUSTERED([id] ASC)
|
153
|
163
|
)
|
154
|
164
|
GO
|
155
|
165
|
|
|
166
|
+DROP SEQUENCE IF EXISTS [post_tags_id_seq]
|
|
167
|
+GO
|
|
168
|
+CREATE SEQUENCE [post_tags_id_seq] AS int START WITH 1 INCREMENT BY 1 NO CACHE
|
|
169
|
+GO
|
|
170
|
+
|
156
|
171
|
CREATE TABLE [post_tags](
|
157
|
|
- [id] [int] IDENTITY,
|
|
172
|
+ [id] [int] NOT NULL CONSTRAINT [post_tags_id_def] DEFAULT NEXT VALUE FOR [post_tags_id_seq],
|
158
|
173
|
[post_id] [int] NOT NULL,
|
159
|
174
|
[tag_id] [int] NOT NULL,
|
160
|
|
- PRIMARY KEY CLUSTERED([id] ASC)
|
|
175
|
+ CONSTRAINT [post_tags_pkey] PRIMARY KEY CLUSTERED([id] ASC)
|
161
|
176
|
)
|
162
|
177
|
GO
|
163
|
178
|
|
|
179
|
+DROP SEQUENCE IF EXISTS [posts_id_seq]
|
|
180
|
+GO
|
|
181
|
+CREATE SEQUENCE [posts_id_seq] AS int START WITH 1 INCREMENT BY 1 NO CACHE
|
|
182
|
+GO
|
|
183
|
+
|
164
|
184
|
CREATE TABLE [posts](
|
165
|
|
- [id] [int] IDENTITY,
|
|
185
|
+ [id] [int] NOT NULL CONSTRAINT [posts_id_def] DEFAULT NEXT VALUE FOR [posts_id_seq],
|
166
|
186
|
[user_id] [int] NOT NULL,
|
167
|
187
|
[category_id] [int] NOT NULL,
|
168
|
188
|
[content] [nvarchar](255) NOT NULL,
|
169
|
|
- PRIMARY KEY CLUSTERED([id] ASC)
|
|
189
|
+ CONSTRAINT [posts_pkey] PRIMARY KEY CLUSTERED([id] ASC)
|
170
|
190
|
)
|
171
|
191
|
GO
|
172
|
192
|
|
|
193
|
+DROP SEQUENCE IF EXISTS [tags_id_seq]
|
|
194
|
+GO
|
|
195
|
+CREATE SEQUENCE [tags_id_seq] AS int START WITH 1 INCREMENT BY 1 NO CACHE
|
|
196
|
+GO
|
|
197
|
+
|
173
|
198
|
CREATE TABLE [tags](
|
174
|
|
- [id] [int] IDENTITY,
|
|
199
|
+ [id] [int] NOT NULL CONSTRAINT [tags_id_def] DEFAULT NEXT VALUE FOR [tags_id_seq],
|
175
|
200
|
[name] [nvarchar](255) NOT NULL,
|
176
|
201
|
[is_important] [bit] NOT NULL,
|
177
|
|
- PRIMARY KEY CLUSTERED([id] ASC)
|
|
202
|
+ CONSTRAINT [tags_pkey] PRIMARY KEY CLUSTERED([id] ASC)
|
178
|
203
|
)
|
179
|
204
|
GO
|
180
|
205
|
|
|
206
|
+DROP SEQUENCE IF EXISTS [users_id_seq]
|
|
207
|
+GO
|
|
208
|
+CREATE SEQUENCE [users_id_seq] AS int START WITH 1 INCREMENT BY 1 NO CACHE
|
|
209
|
+GO
|
|
210
|
+
|
181
|
211
|
CREATE TABLE [users](
|
182
|
|
- [id] [int] IDENTITY,
|
|
212
|
+ [id] [int] NOT NULL CONSTRAINT [users_id_def] DEFAULT NEXT VALUE FOR [users_id_seq],
|
183
|
213
|
[username] [nvarchar](255) NOT NULL,
|
184
|
214
|
[password] [nvarchar](255) NOT NULL,
|
185
|
215
|
[location] [geometry],
|
186
|
|
- CONSTRAINT [PK_users]
|
187
|
|
- PRIMARY KEY CLUSTERED([id] ASC)
|
|
216
|
+ CONSTRAINT [users_pkey] PRIMARY KEY CLUSTERED([id] ASC)
|
188
|
217
|
)
|
189
|
218
|
GO
|
190
|
219
|
|
|
220
|
+DROP SEQUENCE IF EXISTS [countries_id_seq]
|
|
221
|
+GO
|
|
222
|
+CREATE SEQUENCE [countries_id_seq] AS int START WITH 1 INCREMENT BY 1 NO CACHE
|
|
223
|
+GO
|
|
224
|
+
|
191
|
225
|
CREATE TABLE [countries](
|
192
|
|
- [id] [int] IDENTITY,
|
|
226
|
+ [id] [int] NOT NULL CONSTRAINT [countries_id_def] DEFAULT NEXT VALUE FOR [countries_id_seq],
|
193
|
227
|
[name] [nvarchar](255) NOT NULL,
|
194
|
228
|
[shape] [geometry] NOT NULL,
|
195
|
|
- CONSTRAINT [PK_countries]
|
196
|
|
- PRIMARY KEY CLUSTERED([id] ASC)
|
|
229
|
+ CONSTRAINT [countries_pkey] PRIMARY KEY CLUSTERED([id] ASC)
|
197
|
230
|
)
|
198
|
231
|
GO
|
199
|
232
|
|
|
233
|
+DROP SEQUENCE IF EXISTS [events_id_seq]
|
|
234
|
+GO
|
|
235
|
+CREATE SEQUENCE [events_id_seq] AS int START WITH 1 INCREMENT BY 1 NO CACHE
|
|
236
|
+GO
|
|
237
|
+
|
200
|
238
|
CREATE TABLE [events](
|
201
|
|
- [id] [int] IDENTITY,
|
|
239
|
+ [id] [int] NOT NULL CONSTRAINT [events_id_def] DEFAULT NEXT VALUE FOR [events_id_seq],
|
202
|
240
|
[name] [nvarchar](255) NOT NULL,
|
203
|
241
|
[datetime] [datetime2](0),
|
204
|
242
|
[visitors] [bigint],
|
205
|
|
- CONSTRAINT [PK_events]
|
206
|
|
- PRIMARY KEY CLUSTERED([id] ASC)
|
|
243
|
+ CONSTRAINT [events_pkey] PRIMARY KEY CLUSTERED([id] ASC)
|
207
|
244
|
)
|
208
|
245
|
GO
|
209
|
246
|
|
|
@@ -212,25 +249,33 @@ AS
|
212
|
249
|
SELECT top 100 PERCENT name, COUNT_BIG(name) AS [count] FROM tags, post_tags WHERE tags.id = post_tags.tag_id GROUP BY name ORDER BY [count] DESC, name
|
213
|
250
|
GO
|
214
|
251
|
|
|
252
|
+DROP SEQUENCE IF EXISTS [products_id_seq]
|
|
253
|
+GO
|
|
254
|
+CREATE SEQUENCE [products_id_seq] AS int START WITH 1 INCREMENT BY 1 NO CACHE
|
|
255
|
+GO
|
|
256
|
+
|
215
|
257
|
CREATE TABLE [products](
|
216
|
|
- [id] [int] IDENTITY,
|
|
258
|
+ [id] [int] NOT NULL CONSTRAINT [products_id_def] DEFAULT NEXT VALUE FOR [products_id_seq],
|
217
|
259
|
[name] [nvarchar](255) NOT NULL,
|
218
|
260
|
[price] [decimal](10,2) NOT NULL,
|
219
|
261
|
[properties] [xml] NOT NULL,
|
220
|
262
|
[created_at] [datetime2](0) NOT NULL,
|
221
|
263
|
[deleted_at] [datetime2](0),
|
222
|
|
- CONSTRAINT [PK_products]
|
223
|
|
- PRIMARY KEY CLUSTERED([id] ASC)
|
|
264
|
+ CONSTRAINT [products_pkey] PRIMARY KEY CLUSTERED([id] ASC)
|
224
|
265
|
)
|
225
|
266
|
GO
|
226
|
267
|
|
|
268
|
+DROP SEQUENCE IF EXISTS [barcodes_id_seq]
|
|
269
|
+GO
|
|
270
|
+CREATE SEQUENCE [barcodes_id_seq] AS int START WITH 1 INCREMENT BY 1 NO CACHE
|
|
271
|
+GO
|
|
272
|
+
|
227
|
273
|
CREATE TABLE [barcodes](
|
228
|
|
- [id] [int] IDENTITY,
|
|
274
|
+ [id] [int] NOT NULL CONSTRAINT [barcodes_id_def] DEFAULT NEXT VALUE FOR [barcodes_id_seq],
|
229
|
275
|
[product_id] [int] NOT NULL,
|
230
|
276
|
[hex] [nvarchar](255) NOT NULL,
|
231
|
277
|
[bin] [varbinary](max) NOT NULL,
|
232
|
|
- CONSTRAINT [PK_barcodes]
|
233
|
|
- PRIMARY KEY CLUSTERED([id] ASC)
|
|
278
|
+ CONSTRAINT [barcodes_pkey] PRIMARY KEY CLUSTERED([id] ASC)
|
234
|
279
|
)
|
235
|
280
|
GO
|
236
|
281
|
|
|
@@ -239,15 +284,13 @@ CREATE TABLE [kunsthåndværk](
|
239
|
284
|
[Umlauts ä_ö_ü-COUNT] [int] NOT NULL,
|
240
|
285
|
[user_id] [int] NOT NULL,
|
241
|
286
|
[invisible] [nvarchar](36),
|
242
|
|
- CONSTRAINT [PK_kunsthåndværk]
|
243
|
|
- PRIMARY KEY CLUSTERED([id] ASC)
|
|
287
|
+ CONSTRAINT [kunsthåndværk_pkey] PRIMARY KEY CLUSTERED([id] ASC)
|
244
|
288
|
)
|
245
|
289
|
GO
|
246
|
290
|
|
247
|
291
|
CREATE TABLE [invisibles](
|
248
|
292
|
[id] [nvarchar](36) NOT NULL,
|
249
|
|
- CONSTRAINT [PK_invisibles]
|
250
|
|
- PRIMARY KEY CLUSTERED([id] ASC)
|
|
293
|
+ CONSTRAINT [invisibles_pkey] PRIMARY KEY CLUSTERED([id] ASC)
|
251
|
294
|
)
|
252
|
295
|
GO
|
253
|
296
|
|
|
@@ -321,53 +364,53 @@ GO
|
321
|
364
|
INSERT [nopk] ([id]) VALUES ('e42c77c6-06a4-4502-816c-d112c7142e6d')
|
322
|
365
|
GO
|
323
|
366
|
|
324
|
|
-ALTER TABLE [comments] WITH CHECK ADD CONSTRAINT [FK_comments_posts] FOREIGN KEY([post_id])
|
|
367
|
+ALTER TABLE [comments] WITH CHECK ADD CONSTRAINT [comments_post_id_fkey] FOREIGN KEY([post_id])
|
325
|
368
|
REFERENCES [posts] ([id])
|
326
|
369
|
GO
|
327
|
|
-ALTER TABLE [comments] CHECK CONSTRAINT [FK_comments_posts]
|
|
370
|
+ALTER TABLE [comments] CHECK CONSTRAINT [comments_post_id_fkey]
|
328
|
371
|
GO
|
329
|
372
|
|
330
|
|
-ALTER TABLE [comments] WITH CHECK ADD CONSTRAINT [FK_comments_categories] FOREIGN KEY([category_id])
|
|
373
|
+ALTER TABLE [comments] WITH CHECK ADD CONSTRAINT [comments_category_id_fkey] FOREIGN KEY([category_id])
|
331
|
374
|
REFERENCES [categories] ([id])
|
332
|
375
|
GO
|
333
|
|
-ALTER TABLE [comments] CHECK CONSTRAINT [FK_comments_categories]
|
|
376
|
+ALTER TABLE [comments] CHECK CONSTRAINT [comments_category_id_fkey]
|
334
|
377
|
GO
|
335
|
378
|
|
336
|
|
-ALTER TABLE [post_tags] WITH CHECK ADD CONSTRAINT [FK_post_tags_posts] FOREIGN KEY([post_id])
|
|
379
|
+ALTER TABLE [post_tags] WITH CHECK ADD CONSTRAINT [post_tags_post_id_fkey] FOREIGN KEY([post_id])
|
337
|
380
|
REFERENCES [posts] ([id])
|
338
|
381
|
GO
|
339
|
|
-ALTER TABLE [post_tags] CHECK CONSTRAINT [FK_post_tags_posts]
|
|
382
|
+ALTER TABLE [post_tags] CHECK CONSTRAINT [post_tags_post_id_fkey]
|
340
|
383
|
GO
|
341
|
384
|
|
342
|
|
-ALTER TABLE [post_tags] WITH CHECK ADD CONSTRAINT [FK_post_tags_tags] FOREIGN KEY([tag_id])
|
|
385
|
+ALTER TABLE [post_tags] WITH CHECK ADD CONSTRAINT [post_tags_tag_id_fkey] FOREIGN KEY([tag_id])
|
343
|
386
|
REFERENCES [tags] ([id])
|
344
|
387
|
GO
|
345
|
|
-ALTER TABLE [post_tags] CHECK CONSTRAINT [FK_post_tags_tags]
|
|
388
|
+ALTER TABLE [post_tags] CHECK CONSTRAINT [post_tags_tag_id_fkey]
|
346
|
389
|
GO
|
347
|
390
|
|
348
|
|
-ALTER TABLE [posts] WITH CHECK ADD CONSTRAINT [FK_posts_categories] FOREIGN KEY([category_id])
|
|
391
|
+ALTER TABLE [posts] WITH CHECK ADD CONSTRAINT [posts_category_id_fkey] FOREIGN KEY([category_id])
|
349
|
392
|
REFERENCES [categories] ([id])
|
350
|
393
|
GO
|
351
|
|
-ALTER TABLE [posts] CHECK CONSTRAINT [FK_posts_categories]
|
|
394
|
+ALTER TABLE [posts] CHECK CONSTRAINT [posts_category_id_fkey]
|
352
|
395
|
GO
|
353
|
396
|
|
354
|
|
-ALTER TABLE [posts] WITH CHECK ADD CONSTRAINT [FK_posts_users] FOREIGN KEY([user_id])
|
|
397
|
+ALTER TABLE [posts] WITH CHECK ADD CONSTRAINT [posts_user_id_fkey] FOREIGN KEY([user_id])
|
355
|
398
|
REFERENCES [users] ([id])
|
356
|
399
|
GO
|
357
|
|
-ALTER TABLE [posts] CHECK CONSTRAINT [FK_posts_users]
|
|
400
|
+ALTER TABLE [posts] CHECK CONSTRAINT [posts_user_id_fkey]
|
358
|
401
|
GO
|
359
|
402
|
|
360
|
|
-ALTER TABLE [barcodes] WITH CHECK ADD CONSTRAINT [FK_barcodes_products] FOREIGN KEY([product_id])
|
|
403
|
+ALTER TABLE [barcodes] WITH CHECK ADD CONSTRAINT [barcodes_product_id_fkey] FOREIGN KEY([product_id])
|
361
|
404
|
REFERENCES [products] ([id])
|
362
|
405
|
GO
|
363
|
|
-ALTER TABLE [barcodes] CHECK CONSTRAINT [FK_barcodes_products]
|
|
406
|
+ALTER TABLE [barcodes] CHECK CONSTRAINT [barcodes_product_id_fkey]
|
364
|
407
|
GO
|
365
|
408
|
|
366
|
409
|
ALTER TABLE [kunsthåndværk] WITH CHECK ADD CONSTRAINT [UC_kunsthåndværk_Umlauts ä_ö_ü-COUNT] UNIQUE([Umlauts ä_ö_ü-COUNT])
|
367
|
410
|
GO
|
368
|
411
|
|
369
|
|
-ALTER TABLE [kunsthåndværk] WITH CHECK ADD CONSTRAINT [FK_kunsthåndværk_users] FOREIGN KEY([user_id])
|
|
412
|
+ALTER TABLE [kunsthåndværk] WITH CHECK ADD CONSTRAINT [kunsthåndværk_user_id_fkey] FOREIGN KEY([user_id])
|
370
|
413
|
REFERENCES [users] ([id])
|
371
|
414
|
GO
|
372
|
|
-ALTER TABLE [kunsthåndværk] CHECK CONSTRAINT [FK_kunsthåndværk_users]
|
|
415
|
+ALTER TABLE [kunsthåndværk] CHECK CONSTRAINT [kunsthåndværk_user_id_fkey]
|
373
|
416
|
GO
|