feat: category crud
This commit is contained in:
11
migrations/2024-07-07-151037_base_schema/down.sql
Normal file
11
migrations/2024-07-07-151037_base_schema/down.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE IF EXISTS "categories";
|
||||
DROP TABLE IF EXISTS "tags";
|
||||
DROP TABLE IF EXISTS "books";
|
||||
DROP TABLE IF EXISTS "transactions";
|
||||
DROP TABLE IF EXISTS "transaction_tag_rels";
|
||||
DROP TABLE IF EXISTS "accounts";
|
||||
DROP TABLE IF EXISTS "amounts";
|
||||
|
||||
DROP TABLE IF EXISTS "users";
|
||||
81
migrations/2024-07-07-151037_base_schema/up.sql
Normal file
81
migrations/2024-07-07-151037_base_schema/up.sql
Normal file
@@ -0,0 +1,81 @@
|
||||
-- Your SQL goes here
|
||||
-- Your SQL goes here
|
||||
CREATE TABLE "categories" (
|
||||
"id" BIGSERIAL PRIMARY KEY,
|
||||
"uid" BIGINT NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"is_delete" BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
"create_at" TIMESTAMP NOT NULL DEFAULT current_timestamp,
|
||||
"update_at" TIMESTAMP NOT NULL DEFAULT current_timestamp
|
||||
);
|
||||
|
||||
CREATE TABLE "tags" (
|
||||
"id" BIGSERIAL PRIMARY KEY,
|
||||
"uid" BIGINT NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"is_delete" BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
"create_at" TIMESTAMP NOT NULL DEFAULT current_timestamp,
|
||||
"update_at" TIMESTAMP NOT NULL DEFAULT current_timestamp
|
||||
);
|
||||
|
||||
CREATE TABLE "books" (
|
||||
"id" BIGSERIAL PRIMARY KEY,
|
||||
"uid" BIGINT NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"is_delete" BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
"create_at" TIMESTAMP NOT NULL DEFAULT current_timestamp,
|
||||
"update_at" TIMESTAMP NOT NULL DEFAULT current_timestamp
|
||||
);
|
||||
|
||||
CREATE TABLE "transactions" (
|
||||
"id" BIGSERIAL PRIMARY KEY,
|
||||
"uid" BIGINT NOT NULL,
|
||||
"book_id" BIGINT NOT NULL,
|
||||
"description" TEXT NOT NULL,
|
||||
"category_id" BIGINT NOT NULL,
|
||||
"is_delete" BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
"time" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT current_timestamp,
|
||||
"create_at" TIMESTAMP NOT NULL DEFAULT current_timestamp,
|
||||
"update_at" TIMESTAMP NOT NULL DEFAULT current_timestamp
|
||||
);
|
||||
|
||||
CREATE TABLE "transaction_tag_rels" (
|
||||
"id" BIGSERIAL PRIMARY KEY,
|
||||
"uid" BIGINT NOT NULL,
|
||||
"transaction_id" BIGINT NOT NULL,
|
||||
"tag_id" BIGINT NOT NULL,
|
||||
"is_delete" BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
"create_at" TIMESTAMP NOT NULL DEFAULT current_timestamp,
|
||||
"update_at" TIMESTAMP NOT NULL DEFAULT current_timestamp
|
||||
);
|
||||
|
||||
CREATE TABLE "accounts" (
|
||||
"id" BIGSERIAL PRIMARY KEY,
|
||||
"uid" BIGINT NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"type" BIGINT NOT NULL DEFAULT 0,
|
||||
"is_delete" BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
"create_at" TIMESTAMP NOT NULL DEFAULT current_timestamp,
|
||||
"update_at" TIMESTAMP NOT NULL DEFAULT current_timestamp
|
||||
);
|
||||
|
||||
CREATE TABLE "amounts" (
|
||||
"id" BIGSERIAL PRIMARY KEY,
|
||||
"uid" BIGINT NOT NULL,
|
||||
"transaction_id" BIGINT NOT NULL,
|
||||
"value" BIGINT NOT NULL DEFAULT 0,
|
||||
"expo" BIGINT NOT NULL DEFAULT 5,
|
||||
"is_delete" BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
"create_at" TIMESTAMP NOT NULL DEFAULT current_timestamp,
|
||||
"update_at" TIMESTAMP NOT NULL DEFAULT current_timestamp
|
||||
);
|
||||
|
||||
CREATE TABLE "users" (
|
||||
"id" BIGSERIAL PRIMARY KEY,
|
||||
"username" TEXT NOT NULL,
|
||||
"password" TEXT NOT NULL,
|
||||
"mail" TEXT NOT NULL,
|
||||
"is_delete" BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
"create_at" TIMESTAMP NOT NULL DEFAULT current_timestamp,
|
||||
"update_at" TIMESTAMP NOT NULL DEFAULT current_timestamp
|
||||
);
|
||||
Reference in New Issue
Block a user