CREATE TABLE IF NOT EXISTS Badges (Id INTEGER NOT NULL, BadgeNum TEXT, VendLimit INTEGER NOT NULL, CONSTRAINT PK_Badges PRIMARY KEY(Id AUTOINCREMENT));
CREATE TABLE IF NOT EXISTS Balances (Id INTEGER NOT NULL, Amount TEXT NOT NULL, Hash TEXT, AccountId TEXT, Attributes TEXT, LastUpdated TEXT NOT NULL, Created TEXT NOT NULL, CONSTRAINT PK_Balances PRIMARY KEY(Id AUTOINCREMENT));
CREATE TABLE IF NOT EXISTS Bills (Id INTEGER NOT NULL, AcceptedDate TEXT NOT NULL, TransactionId TEXT, Denomination TEXT NOT NULL, CollectionDate TEXT, ProcessedDate TEXT, CONSTRAINT PK_Bills PRIMARY KEY(Id AUTOINCREMENT));
CREATE TABLE IF NOT EXISTS DataFiles (Id TEXT NOT NULL, Data BLOB, MimeType TEXT, MD5Hash TEXT, CONSTRAINT PK_DataFiles PRIMARY KEY(Id));
CREATE TABLE IF NOT EXISTS Displayograms (Id INTEGER NOT NULL, Days TEXT, 'Default' INTEGER NOT NULL, StartTime TEXT NOT NULL, EndTime TEXT NOT NULL, CONSTRAINT PK_Displayograms PRIMARY KEY(Id AUTOINCREMENT));
CREATE TABLE IF NOT EXISTS Fingerprints (Id INTEGER NOT NULL, TokenData TEXT, FmdData TEXT, AccountId TEXT, Created TEXT NOT NULL, LastAccessed TEXT NOT NULL, CONSTRAINT PK_Fingerprints PRIMARY KEY(Id AUTOINCREMENT));
CREATE TABLE IF NOT EXISTS Languages (Key TEXT NOT NULL, Value TEXT, Description TEXT, Code TEXT, CONSTRAINT PK_Languages PRIMARY KEY(Key));
CREATE TABLE IF NOT EXISTS Messages (Id INTEGER NOT NULL, MessageTime TEXT NOT NULL, MessageType INTEGER NOT NULL, Receipient TEXT, Subject TEXT, Body TEXT, Attachments TEXT, Sale TEXT, ProcessedDate TEXT, CONSTRAINT PK_Messages PRIMARY KEY(Id AUTOINCREMENT));
CREATE TABLE IF NOT EXISTS PlanogramSlots (Id INTEGER NOT NULL, SlotNum INTEGER NOT NULL, ProductCode TEXT, Active INTEGER NOT NULL, Par INTEGER NOT NULL, FillDate TEXT NOT NULL, Created TEXT NOT NULL, LastUpdated TEXT NOT NULL, CONSTRAINT PK_PlanogramSlots PRIMARY KEY(Id AUTOINCREMENT));
CREATE TABLE IF NOT EXISTS Products (Id INTEGER NOT NULL, Code TEXT, Name TEXT, Selection TEXT, Price TEXT NOT NULL, TaxID1 TEXT, TaxName1 TEXT, Tax1 TEXT NOT NULL, TaxRate1 TEXT NOT NULL, TaxID2 TEXT, TaxName2 TEXT, Tax2 TEXT NOT NULL, TaxRate2 TEXT NOT NULL, TaxID3 TEXT, TaxName3 TEXT, Tax3 TEXT NOT NULL, TaxRate3 TEXT NOT NULL, TaxID4 TEXT, TaxName4 TEXT, Tax4 TEXT NOT NULL, TaxRate4 TEXT NOT NULL, Deposit TEXT NOT NULL, Fee TEXT NOT NULL, Discount TEXT NOT NULL, Area TEXT, CategoryCode TEXT, Category TEXT, Barcodes TEXT, HotButton TEXT, TempLock INTEGER NOT NULL, CONSTRAINT PK_Products PRIMARY KEY(Id AUTOINCREMENT));
CREATE TABLE IF NOT EXISTS Reloads (Id INTEGER NOT NULL, TransactionId TEXT, TransactionDate TEXT NOT NULL, ReloadAmount TEXT NOT NULL, PaymentTypeId INTEGER NOT NULL, PaymentTransactionId TEXT, ProcessedDate TEXT, CONSTRAINT PK_Reloads PRIMARY KEY(Id AUTOINCREMENT));
CREATE TABLE IF NOT EXISTS Sales (Id INTEGER NOT NULL, TransactionId TEXT, TransactionDate TEXT NOT NULL, BadgeNum TEXT, TaxTotal TEXT NOT NULL, DiscountTotal TEXT NOT NULL, FeeTotal TEXT NOT NULL, DepositTotal TEXT NOT NULL, ProductTotal TEXT NOT NULL, GrandTotal TEXT NOT NULL, TieredPricing INTEGER NOT NULL, PaymentTypeId INTEGER NOT NULL, ProcessedDate TEXT, CONSTRAINT PK_Sales PRIMARY KEY(Id AUTOINCREMENT));
CREATE TABLE IF NOT EXISTS Settings (Name TEXT NOT NULL, Value TEXT, LocalOnly INTEGER NOT NULL, LastModified TEXT NOT NULL, CONSTRAINT PK_Settings PRIMARY KEY(Name));
CREATE TABLE IF NOT EXISTS Transactions (Id INTEGER NOT NULL, TransactionId TEXT, TransactionDate TEXT NOT NULL, TransactionType TEXT, TransactionMethod TEXT, CardSwipeData TEXT, TransactionData TEXT, TransactionResult TEXT, SaleData TEXT, StoredValueInfo TEXT, ReloadAmount TEXT NOT NULL, Barcode TEXT, BadgeNum TEXT, Token TEXT, ReloadTransactionId INTEGER NOT NULL, NumberOfAttempts INTEGER NOT NULL, Offline INTEGER NOT NULL, InsufficientFunds INTEGER NOT NULL, LastAttempt TEXT NOT NULL, Status TEXT, CONSTRAINT PK_Transactions PRIMARY KEY(Id AUTOINCREMENT));
CREATE TABLE IF NOT EXISTS Advertisements (Id INTEGER NOT NULL, AdvertisementType INTEGER NOT NULL, Title TEXT, Description TEXT, StartDate TEXT, EndDate TEXT, ScreenSaver INTEGER NOT NULL, HomeScreen INTEGER NOT NULL, FullScreen INTEGER NOT NULL, ShowTitle INTEGER NOT NULL, LastUpdatedUtc TEXT NOT NULL, NumberOfViews INTEGER NOT NULL, DataFileGuid TEXT, ProductId INTEGER NOT NULL, MD5Hash TEXT, CONSTRAINT FK_Advertisements_DataFiles_DataFileGuid FOREIGN KEY(DataFileGuid) REFERENCES DataFiles(Id) ON DELETE RESTRICT, CONSTRAINT PK_Advertisements PRIMARY KEY(Id AUTOINCREMENT));
CREATE TABLE IF NOT EXISTS ProductImages (Id INTEGER NOT NULL, ProductCode TEXT, MimeType TEXT, DataFileId TEXT, ImageType TEXT, LastUpdated TEXT NOT NULL, MD5Hash TEXT, CONSTRAINT FK_ProductImages_DataFiles_DataFileId FOREIGN KEY(DataFileId) REFERENCES DataFiles(Id) ON DELETE RESTRICT, CONSTRAINT PK_ProductImages PRIMARY KEY(Id AUTOINCREMENT));
CREATE TABLE IF NOT EXISTS DisplayogramSelections (Id INTEGER NOT NULL, DisplayogramId INTEGER NOT NULL, AlternateName TEXT, ProductCode TEXT, Row INTEGER NOT NULL, Position INTEGER NOT NULL, CONSTRAINT FK_DisplayogramSelections_Displayograms_DisplayogramId FOREIGN KEY(DisplayogramId) REFERENCES Displayograms(Id) ON DELETE CASCADE, CONSTRAINT PK_DisplayogramSelections PRIMARY KEY(Id AUTOINCREMENT));
CREATE TABLE IF NOT EXISTS SaleItems (Id INTEGER NOT NULL, SaleId INTEGER NOT NULL, ProductCode TEXT, ProductName TEXT, Quantity INTEGER NOT NULL, Price TEXT NOT NULL, Tax1 TEXT NOT NULL, TaxRate1 TEXT NOT NULL, TaxName1 TEXT, TaxId1 TEXT, Tax2 TEXT NOT NULL, TaxRate2 TEXT NOT NULL, TaxName2 TEXT, TaxId2 TEXT, Tax3 TEXT NOT NULL, TaxRate3 TEXT NOT NULL, TaxName3 TEXT, TaxId3 TEXT, Tax4 TEXT NOT NULL, TaxRate4 TEXT NOT NULL, TaxName4 TEXT, TaxId4 TEXT, Fee TEXT NOT NULL, Deposit TEXT NOT NULL, Discount TEXT NOT NULL, ScannedBarcode TEXT, CONSTRAINT FK_SaleItems_Sales_SaleId FOREIGN KEY(SaleId) REFERENCES Sales(Id) ON DELETE CASCADE, CONSTRAINT PK_SaleItems PRIMARY KEY(Id AUTOINCREMENT));
CREATE INDEX IF NOT EXISTS IX_Advertisements_DataFileGuid ON Advertisements ( DataFileGuid );
CREATE INDEX IF NOT EXISTS IX_DisplayogramSelections_DisplayogramId ON DisplayogramSelections ( DisplayogramId );
CREATE INDEX IF NOT EXISTS IX_ProductImages_DataFileId ON ProductImages ( DataFileId );
CREATE INDEX IF NOT EXISTS IX_SaleItems_SaleId ON SaleItems ( SaleId );
PRAGMA user_version=1;