implement currency and report
This commit is contained in:
@@ -1,4 +1,26 @@
|
||||
-- Reset schema: drop tables first (children → parents), then recreate.
|
||||
BEGIN TRANSACTION;
|
||||
PRAGMA foreign_keys=OFF;
|
||||
|
||||
-- Drop child tables first to avoid FK constraints
|
||||
DROP TABLE IF EXISTS order_in_points;
|
||||
DROP TABLE IF EXISTS order_out_points;
|
||||
DROP TABLE IF EXISTS orders_in;
|
||||
DROP TABLE IF EXISTS orders_out;
|
||||
DROP TABLE IF EXISTS email;
|
||||
DROP TABLE IF EXISTS subscriptions;
|
||||
DROP TABLE IF EXISTS company_user_access;
|
||||
DROP TABLE IF EXISTS destinations;
|
||||
DROP TABLE IF EXISTS transporters;
|
||||
DROP TABLE IF EXISTS clients;
|
||||
DROP TABLE IF EXISTS currency;
|
||||
DROP TABLE IF EXISTS users;
|
||||
|
||||
PRAGMA foreign_keys=ON;
|
||||
COMMIT;
|
||||
|
||||
-- Users table
|
||||
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL,
|
||||
@@ -18,7 +40,7 @@ CREATE TABLE IF NOT EXISTS users (
|
||||
user_role TEXT NOT NULL DEFAULT 'user' CHECK (user_role IN ('user', 'admin', 'company_user')),
|
||||
company_id INTEGER DEFAULT 0,
|
||||
active INTEGER DEFAULT 1,
|
||||
temporary_passwrd INTEGER DEFAULT 0
|
||||
temporary_password INTEGER DEFAULT 0
|
||||
);
|
||||
|
||||
-- Clients table
|
||||
@@ -79,6 +101,8 @@ CREATE TABLE IF NOT EXISTS orders_out (
|
||||
paid_price DOUBLE PRECISION,
|
||||
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
|
||||
order_status TEXT NOT NULL DEFAULT 'active' CHECK (order_status IN ('active', 'inactive', 'cancelled')),
|
||||
order_in_number TEXT,
|
||||
currency TEXT,
|
||||
FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY(client_id) REFERENCES clients(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY(transporter_id) REFERENCES transporters(id) ON DELETE CASCADE
|
||||
@@ -99,6 +123,7 @@ CREATE TABLE IF NOT EXISTS orders_in (
|
||||
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
|
||||
file_name TEXT,
|
||||
expenses DOUBLE PRECISION,
|
||||
currency TEXT,
|
||||
FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY(client_id) REFERENCES clients(id) ON DELETE CASCADE
|
||||
);
|
||||
@@ -162,3 +187,12 @@ CREATE TABLE IF NOT EXISTS company_user_access (
|
||||
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY(company_user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS currency (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_id INTEGER NOT NULL,
|
||||
name TEXT,
|
||||
value DOUBLE PRECISION,
|
||||
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
);
|
||||
Reference in New Issue
Block a user