· 8 years ago · Apr 26, 2018, 12:50 PM
1--------------------------------------------------------------------------------------------
2--- VALCar
3--------------------------------------------------------------------------------------------
4IF db_name()<>'master' and
5 not exists ( select * from information_schema.tables
6 where table_name='VALCar' and table_type='BASE TABLE')
7BEGIN
8 Print 'Create table [VALCar]';
9 CREATE TABLE [dbo].[VALCar](
10 [Id] BIGINT NOT NULL,
11 [VALLocationId] BIGINT NOT NULL,
12 [DictCarStatus] BIGINT NOT NULL,
13
14 CONSTRAINT [PK_VALCar] PRIMARY KEY ([Id]),
15 CONSTRAINT [FK_VALCar_VALLocation] FOREIGN KEY([VALLocationId]) REFERENCES [dbo].[VALLocation] ([Id])
16 );
17END;
18--- END VALCar
19
20
21--------------------------------------------------------------------------------------------
22--- VALCarData
23--------------------------------------------------------------------------------------------
24IF db_name()<>'master' and
25 not exists ( select * from information_schema.tables
26 where table_name='VALCarData' and table_type='BASE TABLE')
27BEGIN
28 Print 'Create table [VALCarData]';
29 CREATE TABLE [dbo].[VALCarData](
30 [VALCarId] BIGINT NOT NULL,
31 [VALCustomerId] BIGINT NULL,
32 [AutomaticCheckoutDateUTC] DATETIME NULL,
33
34 CONSTRAINT [PK_VALCarData] PRIMARY KEY ([VALCarId]),
35 CONSTRAINT [FK_VALCarData_VALCar] FOREIGN KEY([VALCarId]) REFERENCES [dbo].[VALCar] ([Id]),
36 CONSTRAINT [FK_VALCarData_VALCustomer] FOREIGN KEY([VALCustomerId]) REFERENCES [dbo].[VALCustomer] ([Id])
37 );
38END;
39--- END VALCarData