v4.1.9: Начальная производственная версия
- Полный backend на Hono + TypeScript - SQLite база данных с 38 записями - 3 пользователя: admin, aknaproff, kasutaja - Модальное окно reportModal (4 шага) - Docker конфигурация для Synology ARM - Все миграции (0001-0017) - Frontend: vanilla HTML/JS (original.html)
This commit is contained in:
110
migrations/0001_initial.sql
Executable file
110
migrations/0001_initial.sql
Executable file
@@ -0,0 +1,110 @@
|
||||
PRAGMA foreign_keys = ON;
|
||||
|
||||
-- Users table --------------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
username TEXT NOT NULL UNIQUE,
|
||||
password_hash TEXT NOT NULL,
|
||||
full_name TEXT NOT NULL DEFAULT '',
|
||||
role TEXT NOT NULL DEFAULT 'user' CHECK (role IN ('admin', 'user')),
|
||||
active INTEGER NOT NULL DEFAULT 1,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE TRIGGER IF NOT EXISTS trg_users_updated
|
||||
AFTER UPDATE ON users
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
UPDATE users SET updated_at = CURRENT_TIMESTAMP WHERE id = OLD.id;
|
||||
END;
|
||||
|
||||
-- Production records -------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS production_records (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
month INTEGER NOT NULL CHECK (month BETWEEN 1 AND 12),
|
||||
year INTEGER NOT NULL,
|
||||
client_name TEXT NOT NULL,
|
||||
type TEXT,
|
||||
offer_number TEXT,
|
||||
work_number TEXT,
|
||||
quantity INTEGER NOT NULL DEFAULT 0,
|
||||
color TEXT,
|
||||
notes TEXT,
|
||||
notes_date TEXT,
|
||||
installer TEXT,
|
||||
price REAL NOT NULL DEFAULT 0,
|
||||
arve_checked INTEGER NOT NULL DEFAULT 0,
|
||||
arve_makstud TEXT,
|
||||
price_paid INTEGER NOT NULL DEFAULT 0,
|
||||
deleted INTEGER NOT NULL DEFAULT 0,
|
||||
created_by INTEGER,
|
||||
updated_by INTEGER,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL,
|
||||
FOREIGN KEY (updated_by) REFERENCES users(id) ON DELETE SET NULL
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_production_records_year_month
|
||||
ON production_records (year, month, deleted);
|
||||
|
||||
CREATE TRIGGER IF NOT EXISTS trg_production_records_updated
|
||||
AFTER UPDATE ON production_records
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
UPDATE production_records SET updated_at = CURRENT_TIMESTAMP WHERE id = OLD.id;
|
||||
END;
|
||||
|
||||
-- Status checkboxes --------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS status_checkboxes (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
record_id INTEGER NOT NULL UNIQUE,
|
||||
material_date TEXT,
|
||||
material_confirmed INTEGER NOT NULL DEFAULT 0,
|
||||
material2_date TEXT,
|
||||
material2_confirmed INTEGER NOT NULL DEFAULT 0,
|
||||
package_date TEXT,
|
||||
worksheets_date TEXT,
|
||||
worksheets_confirmed INTEGER NOT NULL DEFAULT 0,
|
||||
worksheets_error INTEGER NOT NULL DEFAULT 0,
|
||||
worksheets_cycle_step INTEGER NOT NULL DEFAULT 0,
|
||||
cutting_date TEXT,
|
||||
cutting_error INTEGER NOT NULL DEFAULT 0,
|
||||
glazing_date TEXT,
|
||||
glazing_error INTEGER NOT NULL DEFAULT 0,
|
||||
ready_date TEXT,
|
||||
ready_error INTEGER NOT NULL DEFAULT 0,
|
||||
issued_date TEXT,
|
||||
issued_error INTEGER NOT NULL DEFAULT 0,
|
||||
problems TEXT,
|
||||
problems_date TEXT,
|
||||
problem_flag INTEGER NOT NULL DEFAULT 0,
|
||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (record_id) REFERENCES production_records(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TRIGGER IF NOT EXISTS trg_status_checkboxes_updated
|
||||
AFTER UPDATE ON status_checkboxes
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
UPDATE status_checkboxes SET updated_at = CURRENT_TIMESTAMP WHERE id = OLD.id;
|
||||
END;
|
||||
|
||||
-- Audit log ----------------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS audit_log (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
record_id INTEGER,
|
||||
user_id INTEGER,
|
||||
action TEXT NOT NULL,
|
||||
field TEXT,
|
||||
old_value TEXT,
|
||||
new_value TEXT,
|
||||
metadata TEXT,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (record_id) REFERENCES production_records(id) ON DELETE SET NULL,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_audit_log_record_id
|
||||
ON audit_log (record_id, created_at DESC);
|
||||
1
migrations/0002_add_user_profile_fields.sql
Executable file
1
migrations/0002_add_user_profile_fields.sql
Executable file
@@ -0,0 +1 @@
|
||||
-- Consolidated into 0001_initial.sql during restoration.
|
||||
1
migrations/0003_extend_production_core.sql
Executable file
1
migrations/0003_extend_production_core.sql
Executable file
@@ -0,0 +1 @@
|
||||
-- Consolidated into 0001_initial.sql during restoration.
|
||||
1
migrations/0004_add_finance_flags.sql
Executable file
1
migrations/0004_add_finance_flags.sql
Executable file
@@ -0,0 +1 @@
|
||||
-- Consolidated into 0001_initial.sql during restoration.
|
||||
1
migrations/0005_add_price_paid_flag.sql
Executable file
1
migrations/0005_add_price_paid_flag.sql
Executable file
@@ -0,0 +1 @@
|
||||
-- Consolidated into 0001_initial.sql during restoration.
|
||||
1
migrations/0006_soft_delete_and_creator.sql
Executable file
1
migrations/0006_soft_delete_and_creator.sql
Executable file
@@ -0,0 +1 @@
|
||||
-- Consolidated into 0001_initial.sql during restoration.
|
||||
1
migrations/0007_add_production_indexes.sql
Executable file
1
migrations/0007_add_production_indexes.sql
Executable file
@@ -0,0 +1 @@
|
||||
-- Consolidated into 0001_initial.sql during restoration.
|
||||
1
migrations/0008_add_material2_and_worksheets.sql
Executable file
1
migrations/0008_add_material2_and_worksheets.sql
Executable file
@@ -0,0 +1 @@
|
||||
-- Consolidated into 0001_initial.sql during restoration.
|
||||
1
migrations/0009_add_status_error_flags.sql
Executable file
1
migrations/0009_add_status_error_flags.sql
Executable file
@@ -0,0 +1 @@
|
||||
-- Consolidated into 0001_initial.sql during restoration.
|
||||
1
migrations/0010_add_material_confirmations.sql
Executable file
1
migrations/0010_add_material_confirmations.sql
Executable file
@@ -0,0 +1 @@
|
||||
-- Consolidated into 0001_initial.sql during restoration.
|
||||
1
migrations/0011_add_notes_and_problems_dates.sql
Executable file
1
migrations/0011_add_notes_and_problems_dates.sql
Executable file
@@ -0,0 +1 @@
|
||||
-- Consolidated into 0001_initial.sql during restoration.
|
||||
1
migrations/0012_add_problems_fields.sql
Executable file
1
migrations/0012_add_problems_fields.sql
Executable file
@@ -0,0 +1 @@
|
||||
-- Consolidated into 0001_initial.sql during restoration.
|
||||
1
migrations/0013_add_management_indexes.sql
Executable file
1
migrations/0013_add_management_indexes.sql
Executable file
@@ -0,0 +1 @@
|
||||
-- Consolidated into 0001_initial.sql during restoration.
|
||||
1
migrations/0014_add_audit_log_username.sql
Executable file
1
migrations/0014_add_audit_log_username.sql
Executable file
@@ -0,0 +1 @@
|
||||
-- Consolidated into 0001_initial.sql during restoration.
|
||||
1
migrations/0015_add_audit_log_meta.sql
Executable file
1
migrations/0015_add_audit_log_meta.sql
Executable file
@@ -0,0 +1 @@
|
||||
-- Consolidated into 0001_initial.sql during restoration.
|
||||
1
migrations/0016_add_additional_indexes.sql
Executable file
1
migrations/0016_add_additional_indexes.sql
Executable file
@@ -0,0 +1 @@
|
||||
-- Consolidated into 0001_initial.sql during restoration.
|
||||
1
migrations/0017_finalize_audit_log_indexes.sql
Executable file
1
migrations/0017_finalize_audit_log_indexes.sql
Executable file
@@ -0,0 +1 @@
|
||||
-- Consolidated into 0001_initial.sql during restoration.
|
||||
Reference in New Issue
Block a user