· 6 years ago · Jun 13, 2019, 02:38 PM
1-- -------------------------------------------------------------
2-- TablePlus 2.4(228)
3--
4-- https://tableplus.com/
5--
6-- Database: BagyDBDev2
7-- Generation Time: 2019-06-13 11:35:02.4570
8-- -------------------------------------------------------------
9
10
11DROP TABLE IF EXISTS [dbo].[Addresses];
12-- This script only contains the table creation statements and does not fully represent the table in the database. It's still missing: sequences, indices, triggers. Do not use it as a backup.
13
14CREATE TABLE [dbo].[Addresses] (
15 [Id] int,
16 [PostalCode] int,
17 [Street] varchar(75),
18 [Number] smallint,
19 [Details] varchar(30),
20 [Neighborhood] varchar(20),
21 [City] varchar(50),
22 [State] varchar(2),
23 [Country] varchar(20),
24 PRIMARY KEY ([Id])
25);
26
27DROP TABLE IF EXISTS [dbo].[AppleInAppPurchases];
28-- This script only contains the table creation statements and does not fully represent the table in the database. It's still missing: sequences, indices, triggers. Do not use it as a backup.
29
30CREATE TABLE [dbo].[AppleInAppPurchases] (
31 [Id] int,
32 [Plan] varchar(MAX),
33 [ExpirationDate] datetime,
34 [OriginalTransactionId] varchar(MAX),
35 [StoreId] int,
36 CONSTRAINT [FK__AppleInAp__Store__412EB0B6] FOREIGN KEY ([StoreId]) REFERENCES [dbo].[Stores]([Id]) ON DELETE 1,
37 PRIMARY KEY ([Id])
38);
39
40DROP TABLE IF EXISTS [dbo].[CommonFreights];
41-- This script only contains the table creation statements and does not fully represent the table in the database. It's still missing: sequences, indices, triggers. Do not use it as a backup.
42
43CREATE TABLE [dbo].[CommonFreights] (
44 [Id] int,
45 [AdditionalDeliveryTermInDays] smallint,
46 [CorreiosEnabled] bit,
47 [LocalPickupEnabled] bit,
48 [StoreId] int,
49 CONSTRAINT [FK__CommonFre__Store__440B1D61] FOREIGN KEY ([StoreId]) REFERENCES [dbo].[Stores]([Id]) ON DELETE 1,
50 PRIMARY KEY ([Id])
51);
52
53DROP TABLE IF EXISTS [dbo].[Customers];
54-- This script only contains the table creation statements and does not fully represent the table in the database. It's still missing: sequences, indices, triggers. Do not use it as a backup.
55
56CREATE TABLE [dbo].[Customers] (
57 [Id] int,
58 [Name] varchar(50),
59 [LastName] varchar(50),
60 [DocumentType] smallint,
61 [DocumentNumber] varchar(20),
62 [Email] varchar(50),
63 [PhoneAreaCode] smallint,
64 [PhoneNumber] int,
65 [MobilePhoneAreaCode] smallint,
66 [MobilePhoneNumber] int,
67 [BirthDate] datetime,
68 [RegisterDate] datetime,
69 [PasswordHash] varchar(270),
70 [AddressId] int,
71 CONSTRAINT [FK__Customers__Addre__4BAC3F29] FOREIGN KEY ([AddressId]) REFERENCES [dbo].[Addresses]([Id]) ON DELETE 1,
72 PRIMARY KEY ([Id])
73);
74
75DROP TABLE IF EXISTS [dbo].[CustomFreights];
76-- This script only contains the table creation statements and does not fully represent the table in the database. It's still missing: sequences, indices, triggers. Do not use it as a backup.
77
78CREATE TABLE [dbo].[CustomFreights] (
79 [Id] int,
80 [Name] varchar(50),
81 [DeliveryTermType] smallint,
82 [DeliveryTerm] smallint,
83 [Price] float,
84 [MinimumPurchaseValue] float,
85 [StoreId] int,
86 CONSTRAINT [FK__CustomFre__Store__46E78A0C] FOREIGN KEY ([StoreId]) REFERENCES [dbo].[Stores]([Id]) ON DELETE 1,
87 PRIMARY KEY ([Id])
88);
89
90DROP TABLE IF EXISTS [dbo].[DeliveryAreas];
91-- This script only contains the table creation statements and does not fully represent the table in the database. It's still missing: sequences, indices, triggers. Do not use it as a backup.
92
93CREATE TABLE [dbo].[DeliveryAreas] (
94 [Id] int,
95 [DeliveryAreaType] smallint,
96 [DeliveryArea] varchar(100),
97 [CustomFreightId] int,
98 CONSTRAINT [FK__DeliveryA__Custo__48CFD27E] FOREIGN KEY ([CustomFreightId]) REFERENCES [dbo].[CustomFreights]([Id]) ON DELETE 1
99);
100
101DROP TABLE IF EXISTS [dbo].[DiscountCoupons];
102-- This script only contains the table creation statements and does not fully represent the table in the database. It's still missing: sequences, indices, triggers. Do not use it as a backup.
103
104CREATE TABLE [dbo].[DiscountCoupons] (
105 [Id] int,
106 [Text] varchar(20),
107 [DiscountPercentage] float,
108 [Quantity] smallint,
109 [Enabled] bit,
110 [ExpirationDate] datetime,
111 [StoreId] int,
112 CONSTRAINT [FK__DiscountC__Store__52593CB8] FOREIGN KEY ([StoreId]) REFERENCES [dbo].[Stores]([Id]) ON DELETE 1,
113 PRIMARY KEY ([Id])
114);
115
116DROP TABLE IF EXISTS [dbo].[HotmartActivationCodes];
117-- This script only contains the table creation statements and does not fully represent the table in the database. It's still missing: sequences, indices, triggers. Do not use it as a backup.
118
119CREATE TABLE [dbo].[HotmartActivationCodes] (
120 [Id] int,
121 [SubscriberCode] varchar(50),
122 [Email] varchar(50),
123 [Status] smallint,
124 [LastChangeDate] datetime,
125 [StoreId] int,
126 CONSTRAINT [FK__HotmartAc__Store__5AEE82B9] FOREIGN KEY ([StoreId]) REFERENCES [dbo].[Stores]([Id]) ON DELETE 1,
127 PRIMARY KEY ([Id])
128);
129
130DROP TABLE IF EXISTS [dbo].[HotmartWebhook];
131-- This script only contains the table creation statements and does not fully represent the table in the database. It's still missing: sequences, indices, triggers. Do not use it as a backup.
132
133CREATE TABLE [dbo].[HotmartWebhook] (
134 [Id] int,
135 [ProductCode] bigint,
136 [OfferId] varchar(25),
137 [Price] decimal(18,2),
138 [Email] varchar(100),
139 [DocumentNumber] bigint,
140 [DocumentType] varchar(25),
141 [AreaCode] smallint,
142 [PhoneNumber] int,
143 [TransactionCode] varchar(50),
144 [PurchaseStatus] varchar(25),
145 [PaymentType] varchar(25),
146 [PlanName] varchar(50),
147 [SubscriberCode] varchar(50),
148 [RecurrencyPeriod] smallint,
149 [CurrentRecurrency] smallint,
150 [SubscriptionStatus] varchar(50),
151 [PurchaseDate] datetime,
152 [PurchaseConfirmationDate] datetime,
153 [BilletUrl] varchar(50),
154 [CurrencyCode] varchar(5),
155 [OriginalPrice] decimal(18,2),
156 [WarrantyDate] datetime,
157 [CompleteWebhook] nvarchar(MAX),
158 [WebhookType] varchar(25),
159 [BilletBarCode] varchar(150),
160 [StoreId] int,
161 CONSTRAINT [FK__HotmartWe__Store__5DCAEF64] FOREIGN KEY ([StoreId]) REFERENCES [dbo].[Stores]([Id]) ON DELETE 1,
162 PRIMARY KEY ([Id])
163);
164
165DROP TABLE IF EXISTS [dbo].[OrderFreights];
166-- This script only contains the table creation statements and does not fully represent the table in the database. It's still missing: sequences, indices, triggers. Do not use it as a backup.
167
168CREATE TABLE [dbo].[OrderFreights] (
169 [Id] int,
170 [Type] varchar(20),
171 [DeliveryTerm] varchar(200),
172 [Price] float,
173 [Width] float,
174 [Height] float,
175 [Depth] float,
176 [Weight] float,
177 [Selected] bit,
178 [OrderId] int,
179 [CustomFreightId] int,
180 CONSTRAINT [FK__OrderFrei__Order__787EE5A0] FOREIGN KEY ([OrderId]) REFERENCES [dbo].[Orders]([Id]) ON DELETE 1,
181 CONSTRAINT [FK__OrderFrei__Custo__797309D9] FOREIGN KEY ([CustomFreightId]) REFERENCES [dbo].[CustomFreights]([Id]),
182 PRIMARY KEY ([Id])
183);
184
185DROP TABLE IF EXISTS [dbo].[Orders];
186-- This script only contains the table creation statements and does not fully represent the table in the database. It's still missing: sequences, indices, triggers. Do not use it as a backup.
187
188CREATE TABLE [dbo].[Orders] (
189 [Id] int,
190 [CreationDate] datetime,
191 [Price] float,
192 [Installments] smallint,
193 [Status] smallint,
194 [ExpectedDeliveryTerm] smallint,
195 [DiscountCouponId] int,
196 [CustomerId] int,
197 [StoreId] int,
198 [WirecardOrderStatusId] int,
199 [PagSeguroOrderStatusId] int,
200 CONSTRAINT [FK__Orders__Customer__6D0D32F4] FOREIGN KEY ([CustomerId]) REFERENCES [dbo].[Customers]([Id]),
201 CONSTRAINT [FK__Orders__Wirecard__6EF57B66] FOREIGN KEY ([WirecardOrderStatusId]) REFERENCES [dbo].[WirecardOrderStatus]([Id]) ON DELETE 1,
202 CONSTRAINT [FK__Orders__Discount__6C190EBB] FOREIGN KEY ([DiscountCouponId]) REFERENCES [dbo].[DiscountCoupons]([Id]) ON DELETE 1,
203 CONSTRAINT [FK__Orders__StoreId__6E01572D] FOREIGN KEY ([StoreId]) REFERENCES [dbo].[Stores]([Id]),
204 CONSTRAINT [FK__Orders__PagSegur__6FE99F9F] FOREIGN KEY ([PagSeguroOrderStatusId]) REFERENCES [dbo].[PagSeguroOrderStatus]([Id]) ON DELETE 1,
205 PRIMARY KEY ([Id])
206);
207
208DROP TABLE IF EXISTS [dbo].[OrderTrackings];
209-- This script only contains the table creation statements and does not fully represent the table in the database. It's still missing: sequences, indices, triggers. Do not use it as a backup.
210
211CREATE TABLE [dbo].[OrderTrackings] (
212 [Id] int,
213 [CourierService] smallint,
214 [TrackingCode] varchar(50),
215 [OrderId] int,
216 CONSTRAINT [FK__OrderTrac__Order__75A278F5] FOREIGN KEY ([OrderId]) REFERENCES [dbo].[Orders]([Id]) ON DELETE 1,
217 PRIMARY KEY ([Id])
218);
219
220DROP TABLE IF EXISTS [dbo].[PagSeguroOrderStatus];
221-- This script only contains the table creation statements and does not fully represent the table in the database. It's still missing: sequences, indices, triggers. Do not use it as a backup.
222
223CREATE TABLE [dbo].[PagSeguroOrderStatus] (
224 [Id] int,
225 [TransactionCode] varchar(150),
226 [PagSeguroStatus] smallint,
227 [BagyStatus] smallint,
228 PRIMARY KEY ([Id])
229);
230
231DROP TABLE IF EXISTS [dbo].[PagSeguroStoreCredentials];
232-- This script only contains the table creation statements and does not fully represent the table in the database. It's still missing: sequences, indices, triggers. Do not use it as a backup.
233
234CREATE TABLE [dbo].[PagSeguroStoreCredentials] (
235 [Id] int,
236 [Email] varchar(50),
237 [Token] varchar(150),
238 [InstallmentsWithoutInterest] smallint,
239 [StoreId] int,
240 CONSTRAINT [FK__PagSeguro__Store__60A75C0F] FOREIGN KEY ([StoreId]) REFERENCES [dbo].[Stores]([Id]) ON DELETE 1,
241 PRIMARY KEY ([Id])
242);
243
244DROP TABLE IF EXISTS [dbo].[PagSeguroWebhook];
245-- This script only contains the table creation statements and does not fully represent the table in the database. It's still missing: sequences, indices, triggers. Do not use it as a backup.
246
247CREATE TABLE [dbo].[PagSeguroWebhook] (
248 [Id] int,
249 [DateTime] datetime,
250 [PagSeguroCode] varchar(50),
251 [TransactionStatus] smallint,
252 [Message] varchar(100),
253 [OrderId] int,
254 CONSTRAINT [FK__PagSeguro__Order__72C60C4A] FOREIGN KEY ([OrderId]) REFERENCES [dbo].[Orders]([Id]) ON DELETE 1,
255 PRIMARY KEY ([Id])
256);
257
258DROP TABLE IF EXISTS [dbo].[PaymentGateways];
259-- This script only contains the table creation statements and does not fully represent the table in the database. It's still missing: sequences, indices, triggers. Do not use it as a backup.
260
261CREATE TABLE [dbo].[PaymentGateways] (
262 [Id] int,
263 [ActiveGateway] varchar(20),
264 [StoreId] int,
265 CONSTRAINT [FK__PaymentGa__Store__6383C8BA] FOREIGN KEY ([StoreId]) REFERENCES [dbo].[Stores]([Id]) ON DELETE 1,
266 PRIMARY KEY ([Id])
267);
268
269DROP TABLE IF EXISTS [dbo].[ProductPictures];
270-- This script only contains the table creation statements and does not fully represent the table in the database. It's still missing: sequences, indices, triggers. Do not use it as a backup.
271
272CREATE TABLE [dbo].[ProductPictures] (
273 [Id] int,
274 [Url] varchar(200),
275 [Index] int,
276 [ProductId] int,
277 CONSTRAINT [FK__ProductPi__Produ__5535A963] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Products]([Id]) ON DELETE 1,
278 PRIMARY KEY ([Id])
279);
280
281DROP TABLE IF EXISTS [dbo].[Products];
282-- This script only contains the table creation statements and does not fully represent the table in the database. It's still missing: sequences, indices, triggers. Do not use it as a backup.
283
284CREATE TABLE [dbo].[Products] (
285 [Id] int,
286 [Name] varchar(200),
287 [Description] varchar(500),
288 [Code] varchar(20),
289 [Gender] int,
290 [FinalPrice] float,
291 [OriginalPrice] float,
292 [Width] float,
293 [Height] float,
294 [Weight] float,
295 [Depth] float,
296 [Enabled] bit,
297 [CreatedAt] datetime,
298 [CategoryId] varchar(20),
299 [StoreId] int,
300 CONSTRAINT [FK__Products__StoreI__3E52440B] FOREIGN KEY ([StoreId]) REFERENCES [dbo].[Stores]([Id]) ON DELETE 1,
301 PRIMARY KEY ([Id])
302);
303
304DROP TABLE IF EXISTS [dbo].[ProductVariations];
305-- This script only contains the table creation statements and does not fully represent the table in the database. It's still missing: sequences, indices, triggers. Do not use it as a backup.
306
307CREATE TABLE [dbo].[ProductVariations] (
308 [Id] int,
309 [Name] varchar(20),
310 [Index] int,
311 [Description] varchar(200),
312 [QuantityInStock] int,
313 [Enabled] bit,
314 [ProductId] int,
315 CONSTRAINT [FK__ProductVa__Produ__5812160E] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Products]([Id]) ON DELETE 1,
316 PRIMARY KEY ([Id])
317);
318
319DROP TABLE IF EXISTS [dbo].[StoreContacts];
320-- This script only contains the table creation statements and does not fully represent the table in the database. It's still missing: sequences, indices, triggers. Do not use it as a backup.
321
322CREATE TABLE [dbo].[StoreContacts] (
323 [Id] int,
324 [Email] varchar(50),
325 [PhoneNumber] varchar(25),
326 [WhatsApp] varchar(30),
327 [StoreId] int,
328 CONSTRAINT [FK__StoreCont__Store__66603565] FOREIGN KEY ([StoreId]) REFERENCES [dbo].[Stores]([Id]) ON DELETE 1,
329 PRIMARY KEY ([Id])
330);
331
332DROP TABLE IF EXISTS [dbo].[Stores];
333-- This script only contains the table creation statements and does not fully represent the table in the database. It's still missing: sequences, indices, triggers. Do not use it as a backup.
334
335CREATE TABLE [dbo].[Stores] (
336 [Id] int,
337 [Name] varchar(100),
338 [Description] varchar(150),
339 [Url] varchar(50),
340 [LogoUrl] varchar(200),
341 [InstagramUsername] varchar(30),
342 [DocumentType] smallint,
343 [DocumentNumber] varchar(14),
344 [AddressId] int,
345 CONSTRAINT [FK__Stores__AddressI__38996AB5] FOREIGN KEY ([AddressId]) REFERENCES [dbo].[Addresses]([Id]) ON DELETE 1,
346 PRIMARY KEY ([Id])
347);
348
349DROP TABLE IF EXISTS [dbo].[StoreUsers];
350-- This script only contains the table creation statements and does not fully represent the table in the database. It's still missing: sequences, indices, triggers. Do not use it as a backup.
351
352CREATE TABLE [dbo].[StoreUsers] (
353 [Id] int,
354 [Email] varchar(100),
355 [PasswordHash] varchar(270),
356 [Enabled] bit,
357 [AppleInAppPurchase] bit,
358 [StoreId] int,
359 CONSTRAINT [FK__StoreUser__Store__3B75D760] FOREIGN KEY ([StoreId]) REFERENCES [dbo].[Stores]([Id]) ON DELETE 1,
360 PRIMARY KEY ([Id])
361);
362
363DROP TABLE IF EXISTS [dbo].[WirecardOrderStatus];
364-- This script only contains the table creation statements and does not fully represent the table in the database. It's still missing: sequences, indices, triggers. Do not use it as a backup.
365
366CREATE TABLE [dbo].[WirecardOrderStatus] (
367 [Id] int,
368 [WirecardOrderId] int,
369 [WirecardMultiOrderId] int,
370 [WirecardPaymentId] int,
371 [WirecardMultiPaymentId] int,
372 [WirecardPaymentStatus] int,
373 [WirecardMultiPaymentStatus] int,
374 [BagyStatus] int,
375 PRIMARY KEY ([Id])
376);
377
378DROP TABLE IF EXISTS [dbo].[WirecardStoreCredentials];
379-- This script only contains the table creation statements and does not fully represent the table in the database. It's still missing: sequences, indices, triggers. Do not use it as a backup.
380
381CREATE TABLE [dbo].[WirecardStoreCredentials] (
382 [Id] int,
383 [AccessToken] varchar(100),
384 [ExpiresIn] datetime,
385 [RefreshToken] varchar(100),
386 [Scope] varchar(100),
387 [StoreId] int,
388 CONSTRAINT [FK__WirecardS__Store__693CA210] FOREIGN KEY ([StoreId]) REFERENCES [dbo].[Stores]([Id]) ON DELETE 1,
389 PRIMARY KEY ([Id])
390);