Files

113 lines
3.7 KiB
MySQL
Raw Permalink Normal View History

2024-07-09 17:06:20 +00:00
-- Your SQL goes here
CREATE TABLE "categories" (
"id" BIGSERIAL PRIMARY KEY,
"uid" BIGINT NOT NULL,
2024-08-11 09:25:09 +00:00
"book_id" BIGINT NOT NULL,
2024-07-09 17:06:20 +00:00
"name" TEXT NOT NULL,
2024-07-28 15:04:53 +00:00
"level" INT NOT NULL DEFAULT 0,
"parent_category_id" BIGINT NOT NULL DEFAULT 0,
2024-11-05 00:19:27 +08:00
"op_id" BIGINT NOT NULL DEFAULT 0,
2024-07-09 17:06:20 +00:00
"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,
2024-08-11 09:25:09 +00:00
"book_id" BIGINT NOT NULL,
2024-07-09 17:06:20 +00:00
"name" TEXT NOT NULL,
2024-07-28 15:04:53 +00:00
"level" INT NOT NULL DEFAULT 0,
"parent_tag_id" BIGINT NOT NULL DEFAULT 0,
2024-11-05 00:19:27 +08:00
"op_id" BIGINT NOT NULL DEFAULT 0,
2024-07-09 17:06:20 +00:00
"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,
2024-11-05 00:19:27 +08:00
"op_id" BIGINT NOT NULL DEFAULT 0,
2024-07-09 17:06:20 +00:00
"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,
2024-11-05 00:19:27 +08:00
"op_id" BIGINT NOT NULL DEFAULT 0,
2024-07-09 17:06:20 +00:00
"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,
2024-11-05 00:19:27 +08:00
"op_id" BIGINT NOT NULL DEFAULT 0,
2024-07-09 17:06:20 +00:00
"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,
2024-07-28 15:04:53 +00:00
"account_type" BIGINT NOT NULL DEFAULT 0,
2024-11-05 00:19:27 +08:00
"op_id" BIGINT NOT NULL DEFAULT 0,
2024-07-09 17:06:20 +00:00
"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,
2024-08-11 09:25:09 +00:00
"account_id" BIGINT NOT NULL,
2024-07-09 17:06:20 +00:00
"transaction_id" BIGINT NOT NULL,
"value" BIGINT NOT NULL DEFAULT 0,
"expo" BIGINT NOT NULL DEFAULT 5,
2024-08-11 09:25:09 +00:00
"currency" TEXT NOT NULL DEFAULT '',
2024-11-05 00:19:27 +08:00
"op_id" BIGINT NOT NULL DEFAULT 0,
2024-07-09 17:06:20 +00:00
"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,
2024-07-28 14:24:53 +00:00
"username" TEXT NOT NULL UNIQUE,
2024-07-09 17:06:20 +00:00
"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
);
2024-11-05 00:19:27 +08:00
CREATE TABLE "operations" (
"id" BIGSERIAL PRIMARY KEY,
"uid" BIGINT NOT NULL,
"entity_type" BIGINT NOT NULL,
"entity_id" BIGINT NOT NULL,
"action" BIGINT NOT NULL,
"create_at" TIMESTAMP NOT NULL DEFAULT current_timestamp,
"update_at" TIMESTAMP NOT NULL DEFAULT current_timestamp
);
2024-11-24 11:29:18 +08:00
CREATE TABLE "operation_snapshots" (
"id" BIGSERIAL PRIMARY KEY,
"uid" BIGINT NOT NULL,
"max_op_id" BIGINT NOT NULL,
"create_at" TIMESTAMP NOT NULL DEFAULT current_timestamp
);