active log add

This commit is contained in:
2026-07-16 17:53:45 +05:00
parent 585ba63bc2
commit 3636e1ca53
15 changed files with 856 additions and 29 deletions

View File

@@ -1,28 +1,3 @@
CREATE TABLE IF NOT EXISTS roles (
id bigserial PRIMARY KEY,
code character varying(255) NOT NULL DEFAULT '',
name character varying(255) NOT NULL,
guard_name character varying(255) 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
);
CREATE TABLE IF NOT EXISTS role_user (
id bigserial PRIMARY KEY,
role_id bigint REFERENCES roles(id),
user_id bigint REFERENCES users(id),
created_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 permission_user (
id bigserial PRIMARY KEY,
permission_id bigint REFERENCES permissions(id),
user_id bigint REFERENCES users(id),
created_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 users (
"id" bigserial primary key,
"email" character varying(250) NOT NULL DEFAULT '',
@@ -114,6 +89,31 @@ CREATE TABLE IF NOT EXISTS permissions (
updated_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
);
CREATE TABLE IF NOT EXISTS roles (
id bigserial PRIMARY KEY,
code character varying(255) NOT NULL DEFAULT '',
name character varying(255) NOT NULL,
guard_name character varying(255) 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
);
CREATE TABLE IF NOT EXISTS role_user (
id bigserial PRIMARY KEY,
role_id bigint REFERENCES roles(id),
user_id bigint REFERENCES users(id),
created_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 permission_user (
id bigserial PRIMARY KEY,
permission_id bigint REFERENCES permissions(id),
user_id bigint REFERENCES users(id),
created_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 branch_user (
id bigserial PRIMARY KEY,
branch_id bigint REFERENCES branches(id),

View File

@@ -0,0 +1 @@
DROP TABLE IF EXISTS activity_logs;

View File

@@ -0,0 +1,18 @@
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);