Refactor architecture: improve env loading and command workflow

This commit is contained in:
syntaxbullet
2025-12-05 12:06:29 +01:00
parent f4b72b93e4
commit 48995204a5
16 changed files with 362 additions and 30 deletions

View File

@@ -0,0 +1,22 @@
CREATE TABLE "transactions" (
"transaction_id" serial PRIMARY KEY NOT NULL,
"from_user_id" text,
"to_user_id" text,
"amount" integer NOT NULL,
"occured_at" timestamp DEFAULT now(),
"type" text NOT NULL,
"description" text,
CONSTRAINT "transactions_transaction_id_unique" UNIQUE("transaction_id")
);
--> statement-breakpoint
CREATE TABLE "users" (
"user_id" text PRIMARY KEY NOT NULL,
"balance" integer DEFAULT 0 NOT NULL,
"last_daily" timestamp,
"daily_streak" integer DEFAULT 0 NOT NULL,
"created_at" timestamp DEFAULT now(),
CONSTRAINT "users_user_id_unique" UNIQUE("user_id")
);
--> statement-breakpoint
ALTER TABLE "transactions" ADD CONSTRAINT "transactions_from_user_id_users_user_id_fk" FOREIGN KEY ("from_user_id") REFERENCES "public"."users"("user_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "transactions" ADD CONSTRAINT "transactions_to_user_id_users_user_id_fk" FOREIGN KEY ("to_user_id") REFERENCES "public"."users"("user_id") ON DELETE no action ON UPDATE no action;

View File

@@ -0,0 +1,164 @@
{
"id": "e5884b86-8257-466d-86f8-5fef47cfcd50",
"prevId": "00000000-0000-0000-0000-000000000000",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.transactions": {
"name": "transactions",
"schema": "",
"columns": {
"transaction_id": {
"name": "transaction_id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"from_user_id": {
"name": "from_user_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
"to_user_id": {
"name": "to_user_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
"amount": {
"name": "amount",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"occured_at": {
"name": "occured_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
},
"type": {
"name": "type",
"type": "text",
"primaryKey": false,
"notNull": true
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {
"transactions_from_user_id_users_user_id_fk": {
"name": "transactions_from_user_id_users_user_id_fk",
"tableFrom": "transactions",
"tableTo": "users",
"columnsFrom": [
"from_user_id"
],
"columnsTo": [
"user_id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"transactions_to_user_id_users_user_id_fk": {
"name": "transactions_to_user_id_users_user_id_fk",
"tableFrom": "transactions",
"tableTo": "users",
"columnsFrom": [
"to_user_id"
],
"columnsTo": [
"user_id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"transactions_transaction_id_unique": {
"name": "transactions_transaction_id_unique",
"nullsNotDistinct": false,
"columns": [
"transaction_id"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.users": {
"name": "users",
"schema": "",
"columns": {
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": true,
"notNull": true
},
"balance": {
"name": "balance",
"type": "integer",
"primaryKey": false,
"notNull": true,
"default": 0
},
"last_daily": {
"name": "last_daily",
"type": "timestamp",
"primaryKey": false,
"notNull": false
},
"daily_streak": {
"name": "daily_streak",
"type": "integer",
"primaryKey": false,
"notNull": true,
"default": 0
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"users_user_id_unique": {
"name": "users_user_id_unique",
"nullsNotDistinct": false,
"columns": [
"user_id"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
}
},
"enums": {},
"schemas": {},
"sequences": {},
"roles": {},
"policies": {},
"views": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}

View File

@@ -0,0 +1,13 @@
{
"version": "7",
"dialect": "postgresql",
"entries": [
{
"idx": 0,
"version": "7",
"when": 1764930369542,
"tag": "0000_big_obadiah_stane",
"breakpoints": true
}
]
}