change db

This commit is contained in:
2026-07-09 13:13:18 +05:00
parent d6555e1133
commit c29c72fd92
2 changed files with 14 additions and 4 deletions

View File

@@ -1,6 +1,5 @@
DROP TABLE IF EXISTS loan_orders;
DROP TABLE IF EXISTS branch_user;
DROP TABLE IF EXISTS roles;
DROP TABLE IF EXISTS loan_order_required_docs;
DROP TABLE IF EXISTS loan_types;
DROP TABLE IF EXISTS card_states;
@@ -8,3 +7,4 @@ DROP TABLE IF EXISTS card_types;
DROP TABLE IF EXISTS branches;
DROP TABLE IF EXISTS provinces;
DROP TABLE IF EXISTS users;
DROP TABLE IF EXISTS roles;

View File

@@ -9,9 +9,14 @@ CREATE TABLE IF NOT EXISTS users (
"phone" character varying(250) NOT NULL DEFAULT '',
"light_mode" integer DEFAULT 1 NOT NULL,
"role" character varying(250) NOT NULL DEFAULT 'user',
"role_id" bigint,
"active" boolean NOT NULL DEFAULT true,
"updated_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
"created_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
"created_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
CONSTRAINT users_role_id_fkey
FOREIGN KEY ("role_id")
REFERENCES roles("id")
ON UPDATE CASCADE ON DELETE CASCADE
);
insert into users(
@@ -39,7 +44,7 @@ CREATE TABLE IF NOT EXISTS branches (
name json NOT NULL DEFAULT '{}'::json,
address json NOT NULL DEFAULT '{}'::json,
region character varying(2) NOT NULL DEFAULT '',
province_id bigint REFERENCES provinces(id) ON DELETE SET NULL,
province_id bigint,
phone_numbers json NOT NULL DEFAULT '[]'::json,
billing_username character varying(255) NOT NULL DEFAULT '',
billing_password character varying(255) NOT NULL DEFAULT '',
@@ -51,7 +56,11 @@ CREATE TABLE IF NOT EXISTS branches (
billing_sber_password character varying(255) NOT NULL DEFAULT '',
active boolean NOT NULL DEFAULT true,
"updated_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
"created_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
"created_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
CONSTRAINT branches_province_id_fkey
FOREIGN KEY ("province_id")
REFERENCES provinces("id")
ON UPDATE CASCADE ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS card_types (
@@ -103,6 +112,7 @@ CREATE TABLE IF NOT EXISTS roles (
updated_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
);
CREATE TABLE IF NOT EXISTS permissions (
id bigserial PRIMARY KEY,
code character varying(255) NOT NULL DEFAULT '',