You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
inventory-app/migrations/20241107225934_initial.sql

42 lines
1.1 KiB

-- Add migration script here
CREATE TABLE IF NOT EXISTS User (
id INTEGER PRIMARY KEY NOT NULL,
name TEXT NOT NULL,
role TEXT NOT NULL,
CHECK(role = 'admin' OR role = 'editor' OR role = 'viewer')
);
CREATE TABLE IF NOT EXISTS InventoryItem (
id INTEGER PRIMARY KEY NOT NULL,
name TEXT NOT NULL,
reorder_point INTEGER NOT NULL
);
CREATE TABLE IF NOT EXISTS PositiveAdjustment (
id INTEGER PRIMARY KEY NOT NULL,
user INTEGER NOT NULL,
create_date TIMESTAMP NOT NULL,
target_date TIMESTAMP NOT NULL,
amount INTEGER NOT NULL,
unit_price INTEGER NOT NULL,
FOREIGN KEY(user) REFERENCES User(id)
);
CREATE TABLE IF NOT EXISTS NegativeAdjustment (
id INTEGER PRIMARY KEY NOT NULL,
user INTEGER NOT NULL,
create_date TIMESTAMP NOT NULL,
target_date TIMESTAMP NOT NULL,
amount INTEGER NOT NULL,
reason INTEGER NOT NULL,
FOREIGN KEY(user) REFERENCES User(id),
FOREIGN KEY(reason) REFERENCES NegativeAdjustmentReason(id)
);
CREATE TABLE IF NOT EXISTS NegativeAdjustmentReason (
id INTEGER PRIMARY KEY NOT NULL,
name TEXT NOT NULL
);

Powered by TurnKey Linux.