intrgrating suggestions after betta 1

This commit is contained in:
2025-09-08 18:06:00 +03:00
parent eb262451ad
commit 106045d72a
34 changed files with 1549 additions and 146 deletions

View File

@@ -15,7 +15,10 @@ CREATE TABLE IF NOT EXISTS users (
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
otp_code TEXT,
otp_expiration TIMESTAMPTZ,
user_role TEXT NOT NULL DEFAULT 'user' CHECK (user_role IN ('user', 'admin'))
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
);
-- Clients table
@@ -94,6 +97,8 @@ CREATE TABLE IF NOT EXISTS orders_in (
trailer_reg_number TEXT,
received_price DOUBLE PRECISION,
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
file_name TEXT,
expenses DOUBLE PRECISION,
FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE,
FOREIGN KEY(client_id) REFERENCES clients(id) ON DELETE CASCADE
);
@@ -143,4 +148,17 @@ CREATE TABLE IF NOT EXISTS email (
smtp_user TEXT,
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
);
);
CREATE TABLE IF NOT EXISTS company_user_access (
id INTEGER PRIMARY KEY AUTOINCREMENT,
company_user_id INTEGER NOT NULL,
clients INTEGER,
transporters INTEGER,
destinations INTEGER,
orders_in INTEGER,
orders_out INTEGER,
report INTEGER,
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY(company_user_id) REFERENCES users(id) ON DELETE CASCADE
);