-- noinspection SqlNoDataSourceInspectionForFile

-- Schema: product
-- Brief: Control item availability
-- Created by: ealmeida
-- Table schema_version: must be defined for database update through the Persistence Component

CREATE TABLE schema_version AS
SELECT "$Author: Emilson $" AS Author,
       "$Date: 2016-01-24 13:00:00 -0300 (Sun, 24 Jan 2016) $" AS LastModifiedAt,
       "$Revision:$" AS Revision;

-- ------------------------- --
-- ------------------------- --
-- Ruptura schema definition --
-- ------------------------- --
-- ------------------------- --

-- -----------------------------------------
-- Main database tables for ruptura catalog
-- -----------------------------------------


CREATE TABLE Event (
    Id                       INTEGER PRIMARY KEY AUTOINCREMENT,
    Type                     VARCHAR NOT NULL,
    CreatedAt                DATETIME NOT NULL,
    AdditionalInfo           VARCHAR,
    EnabledPartCodes         VARCHAR,
    DisabledPartCodes        VARCHAR,
    MainDisabledPartCodes    VARCHAR,
    AffectedItems            VARCHAR
);

CREATE TABLE PartCodeQuantity (
    Id                  INTEGER PRIMARY KEY AUTOINCREMENT,
    PartCode            INTEGER NOT NULL,
    Quantity            INTEGER NOT NULL,
    CurrentQuantity     INTEGER NOT NULL,
    CreatedBy           VARCHAR NOT NULL,
    CreatedAt           DATETIME,
    DeletedBy           VARCHAR,
    DeletedAt           DATETIME
);
