Merge activity_logs into init migration and ignore myapp binary.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
3636e1ca53
commit
30bcfefc1e
5 files changed
+62
-62
No files matched your search
@@ -1,5 +1,6 @@
|
|||||||
# Binaries
|
# Binaries
|
||||||
online-back
|
online-back
|
||||||
|
myapp
|
||||||
*.exe
|
*.exe
|
||||||
*.exe~
|
*.exe~
|
||||||
*.dll
|
*.dll
|
||||||
|
|||||||
@@ -1,15 +1,19 @@
|
|||||||
|
DROP TABLE IF EXISTS activity_logs;
|
||||||
DROP TABLE IF EXISTS cards;
|
DROP TABLE IF EXISTS cards;
|
||||||
DROP TABLE IF EXISTS card_pin_orders;
|
DROP TABLE IF EXISTS card_pin_orders;
|
||||||
DROP TABLE IF EXISTS card_orders;
|
DROP TABLE IF EXISTS card_orders;
|
||||||
DROP TABLE IF EXISTS loan_paid_off_letters;
|
DROP TABLE IF EXISTS loan_paid_off_letters;
|
||||||
DROP TABLE IF EXISTS loans;
|
DROP TABLE IF EXISTS loans;
|
||||||
DROP TABLE IF EXISTS loan_orders;
|
DROP TABLE IF EXISTS loan_orders;
|
||||||
DROP TABLE IF EXISTS branch_user;
|
|
||||||
DROP TABLE IF EXISTS loan_order_required_docs;
|
DROP TABLE IF EXISTS loan_order_required_docs;
|
||||||
DROP TABLE IF EXISTS loan_types;
|
DROP TABLE IF EXISTS loan_types;
|
||||||
|
DROP TABLE IF EXISTS branch_user;
|
||||||
|
DROP TABLE IF EXISTS permission_user;
|
||||||
|
DROP TABLE IF EXISTS role_user;
|
||||||
|
DROP TABLE IF EXISTS roles;
|
||||||
|
DROP TABLE IF EXISTS permissions;
|
||||||
DROP TABLE IF EXISTS card_states;
|
DROP TABLE IF EXISTS card_states;
|
||||||
DROP TABLE IF EXISTS card_types;
|
DROP TABLE IF EXISTS card_types;
|
||||||
DROP TABLE IF EXISTS branches;
|
DROP TABLE IF EXISTS branches;
|
||||||
DROP TABLE IF EXISTS provinces;
|
DROP TABLE IF EXISTS provinces;
|
||||||
DROP TABLE IF EXISTS users;
|
DROP TABLE IF EXISTS users;
|
||||||
DROP TABLE IF EXISTS roles;
|
|
||||||
@@ -1,38 +1,37 @@
|
|||||||
CREATE TABLE IF NOT EXISTS users (
|
CREATE TABLE IF NOT EXISTS users (
|
||||||
"id" bigserial primary key,
|
id bigserial PRIMARY KEY,
|
||||||
"email" character varying(250) NOT NULL DEFAULT '',
|
email character varying(250) NOT NULL DEFAULT '',
|
||||||
"password" character varying(250) NOT NULL DEFAULT '',
|
password character varying(250) NOT NULL DEFAULT '',
|
||||||
"name" character varying(255) NOT NULL DEFAULT '',
|
name character varying(255) NOT NULL DEFAULT '',
|
||||||
"first_name" character varying(255) NOT NULL DEFAULT '',
|
first_name character varying(255) NOT NULL DEFAULT '',
|
||||||
"last_name" character varying(255) NOT NULL DEFAULT '',
|
last_name character varying(255) NOT NULL DEFAULT '',
|
||||||
"username" character varying(250) NOT NULL DEFAULT '',
|
username character varying(250) NOT NULL DEFAULT '',
|
||||||
"phone" character varying(250) NOT NULL DEFAULT '',
|
phone character varying(250) NOT NULL DEFAULT '',
|
||||||
"avatar" character varying(250) NOT NULL DEFAULT '',
|
avatar character varying(250) NOT NULL DEFAULT '',
|
||||||
"social_media" json NOT NULL DEFAULT '{}'::json,
|
social_media json NOT NULL DEFAULT '{}'::json,
|
||||||
"light_mode" integer DEFAULT 1 NOT NULL,
|
light_mode integer NOT NULL DEFAULT 1,
|
||||||
"role" character varying(250) NOT NULL DEFAULT 'user',
|
role character varying(250) NOT NULL DEFAULT 'user',
|
||||||
"active" boolean NOT NULL DEFAULT true,
|
active boolean NOT NULL DEFAULT true,
|
||||||
"updated_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
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
|
||||||
);
|
);
|
||||||
|
|
||||||
insert into users(
|
INSERT INTO users (phone, password, name, email, role)
|
||||||
phone, password, name, email, role
|
VALUES (
|
||||||
) values (
|
|
||||||
'61531216',
|
'61531216',
|
||||||
'$2a$12$8ZbKmoSwna4CASQptM2/SubwvsBUR1YhABULd.2/QJB.13Wi2v55m',
|
'$2a$12$8ZbKmoSwna4CASQptM2/SubwvsBUR1YhABULd.2/QJB.13Wi2v55m',
|
||||||
'Admin',
|
'Admin',
|
||||||
'admin@admin.com',
|
'admin@admin.com',
|
||||||
'admin'
|
'admin'
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS provinces (
|
CREATE TABLE IF NOT EXISTS provinces (
|
||||||
id bigserial PRIMARY KEY,
|
id bigserial PRIMARY KEY,
|
||||||
name json NOT NULL DEFAULT '{}'::json,
|
name json NOT NULL DEFAULT '{}'::json,
|
||||||
region json NOT NULL DEFAULT '{}'::json,
|
region json NOT NULL DEFAULT '{}'::json,
|
||||||
active boolean NOT NULL DEFAULT true,
|
active boolean NOT NULL DEFAULT true,
|
||||||
"updated_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
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
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS branches (
|
CREATE TABLE IF NOT EXISTS branches (
|
||||||
@@ -52,12 +51,10 @@ CREATE TABLE IF NOT EXISTS branches (
|
|||||||
billing_sber_username character varying(255) NOT NULL DEFAULT '',
|
billing_sber_username character varying(255) NOT NULL DEFAULT '',
|
||||||
billing_sber_password character varying(255) NOT NULL DEFAULT '',
|
billing_sber_password character varying(255) NOT NULL DEFAULT '',
|
||||||
active boolean NOT NULL DEFAULT true,
|
active boolean NOT NULL DEFAULT true,
|
||||||
"updated_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
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
|
CONSTRAINT branches_province_id_fkey
|
||||||
FOREIGN KEY ("province_id")
|
FOREIGN KEY (province_id) REFERENCES provinces(id) ON UPDATE CASCADE
|
||||||
REFERENCES provinces("id")
|
|
||||||
ON UPDATE CASCADE
|
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS card_types (
|
CREATE TABLE IF NOT EXISTS card_types (
|
||||||
@@ -66,8 +63,8 @@ CREATE TABLE IF NOT EXISTS card_types (
|
|||||||
price character varying(255) NOT NULL DEFAULT '',
|
price character varying(255) NOT NULL DEFAULT '',
|
||||||
notes character varying(255) NOT NULL DEFAULT '',
|
notes character varying(255) NOT NULL DEFAULT '',
|
||||||
active boolean NOT NULL DEFAULT true,
|
active boolean NOT NULL DEFAULT true,
|
||||||
"updated_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
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
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS card_states (
|
CREATE TABLE IF NOT EXISTS card_states (
|
||||||
@@ -213,7 +210,6 @@ CREATE TABLE IF NOT EXISTS loan_orders (
|
|||||||
notes text,
|
notes text,
|
||||||
created_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
created_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
||||||
updated_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
|
updated_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS loans (
|
CREATE TABLE IF NOT EXISTS loans (
|
||||||
@@ -225,7 +221,7 @@ CREATE TABLE IF NOT EXISTS loans (
|
|||||||
created_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
created_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
||||||
updated_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
updated_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
||||||
CONSTRAINT loans_user_id_fkey
|
CONSTRAINT loans_user_id_fkey
|
||||||
FOREIGN KEY ("user_id") REFERENCES users(id)
|
FOREIGN KEY (user_id) REFERENCES users(id)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS loan_paid_off_letters (
|
CREATE TABLE IF NOT EXISTS loan_paid_off_letters (
|
||||||
@@ -251,9 +247,9 @@ CREATE TABLE IF NOT EXISTS loan_paid_off_letters (
|
|||||||
created_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
created_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
||||||
updated_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
updated_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
||||||
CONSTRAINT loan_paid_off_letters_branch_id_fkey
|
CONSTRAINT loan_paid_off_letters_branch_id_fkey
|
||||||
FOREIGN KEY ("branch_id") REFERENCES branches(id),
|
FOREIGN KEY (branch_id) REFERENCES branches(id),
|
||||||
CONSTRAINT loan_paid_off_letters_user_id_fkey
|
CONSTRAINT loan_paid_off_letters_user_id_fkey
|
||||||
FOREIGN KEY ("user_id") REFERENCES users(id)
|
FOREIGN KEY (user_id) REFERENCES users(id)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS card_orders (
|
CREATE TABLE IF NOT EXISTS card_orders (
|
||||||
@@ -290,13 +286,13 @@ CREATE TABLE IF NOT EXISTS card_orders (
|
|||||||
created_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
created_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
||||||
updated_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
updated_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
||||||
CONSTRAINT card_orders_card_state_id_fkey
|
CONSTRAINT card_orders_card_state_id_fkey
|
||||||
FOREIGN KEY ("card_state_id") REFERENCES card_states(id),
|
FOREIGN KEY (card_state_id) REFERENCES card_states(id),
|
||||||
CONSTRAINT card_orders_card_type_id_fkey
|
CONSTRAINT card_orders_card_type_id_fkey
|
||||||
FOREIGN KEY ("card_type_id") REFERENCES card_types(id),
|
FOREIGN KEY (card_type_id) REFERENCES card_types(id),
|
||||||
CONSTRAINT card_orders_branch_id_fkey
|
CONSTRAINT card_orders_branch_id_fkey
|
||||||
FOREIGN KEY ("branch_id") REFERENCES branches(id),
|
FOREIGN KEY (branch_id) REFERENCES branches(id),
|
||||||
CONSTRAINT card_orders_user_id_fkey
|
CONSTRAINT card_orders_user_id_fkey
|
||||||
FOREIGN KEY ("user_id") REFERENCES users(id)
|
FOREIGN KEY (user_id) REFERENCES users(id)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS card_pin_orders (
|
CREATE TABLE IF NOT EXISTS card_pin_orders (
|
||||||
@@ -323,11 +319,11 @@ CREATE TABLE IF NOT EXISTS card_pin_orders (
|
|||||||
created_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
created_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
||||||
updated_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
updated_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
||||||
CONSTRAINT card_pin_orders_card_type_id_fkey
|
CONSTRAINT card_pin_orders_card_type_id_fkey
|
||||||
FOREIGN KEY ("card_type_id") REFERENCES card_types(id),
|
FOREIGN KEY (card_type_id) REFERENCES card_types(id),
|
||||||
CONSTRAINT card_pin_orders_branch_id_fkey
|
CONSTRAINT card_pin_orders_branch_id_fkey
|
||||||
FOREIGN KEY ("branch_id") REFERENCES branches(id),
|
FOREIGN KEY (branch_id) REFERENCES branches(id),
|
||||||
CONSTRAINT card_pin_orders_user_id_fkey
|
CONSTRAINT card_pin_orders_user_id_fkey
|
||||||
FOREIGN KEY ("user_id") REFERENCES users(id)
|
FOREIGN KEY (user_id) REFERENCES users(id)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS cards (
|
CREATE TABLE IF NOT EXISTS cards (
|
||||||
@@ -341,6 +337,24 @@ CREATE TABLE IF NOT EXISTS cards (
|
|||||||
created_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
created_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
||||||
updated_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
updated_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
||||||
CONSTRAINT cards_user_id_fkey
|
CONSTRAINT cards_user_id_fkey
|
||||||
FOREIGN KEY ("user_id") REFERENCES users(id)
|
FOREIGN KEY (user_id) REFERENCES users(id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS activity_logs (
|
||||||
|
id bigserial PRIMARY KEY,
|
||||||
|
user_id bigint,
|
||||||
|
method character varying(10) NOT NULL DEFAULT '',
|
||||||
|
path character varying(255) NOT NULL DEFAULT '',
|
||||||
|
module character varying(100) NOT NULL DEFAULT '',
|
||||||
|
action character varying(50) NOT NULL DEFAULT '',
|
||||||
|
status_code integer NOT NULL DEFAULT 0,
|
||||||
|
request_body jsonb,
|
||||||
|
ip character varying(50) NOT NULL DEFAULT '',
|
||||||
|
created_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
||||||
|
CONSTRAINT activity_logs_user_id_fkey
|
||||||
|
FOREIGN KEY (user_id) REFERENCES users(id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_activity_logs_user_id ON activity_logs(user_id);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_activity_logs_module ON activity_logs(module);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_activity_logs_created_at ON activity_logs(created_at);
|
||||||
@@ -1 +0,0 @@
|
|||||||
DROP TABLE IF EXISTS activity_logs;
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
CREATE TABLE IF NOT EXISTS activity_logs (
|
|
||||||
id bigserial PRIMARY KEY,
|
|
||||||
user_id bigint,
|
|
||||||
method character varying(10) NOT NULL DEFAULT '',
|
|
||||||
path character varying(255) NOT NULL DEFAULT '',
|
|
||||||
module character varying(100) NOT NULL DEFAULT '',
|
|
||||||
action character varying(50) NOT NULL DEFAULT '',
|
|
||||||
status_code integer NOT NULL DEFAULT 0,
|
|
||||||
request_body jsonb,
|
|
||||||
ip character varying(50) NOT NULL DEFAULT '',
|
|
||||||
created_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
|
||||||
CONSTRAINT activity_logs_user_id_fkey
|
|
||||||
FOREIGN KEY ("user_id") REFERENCES users(id)
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_activity_logs_user_id ON activity_logs(user_id);
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_activity_logs_module ON activity_logs(module);
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_activity_logs_created_at ON activity_logs(created_at);
|
|
||||||
Reference in new issue
Block a user