stock-portfolio_byQwen3.6/drizzle/0002_rapid_invaders.sql

15 lines
777 B
SQL

CREATE TYPE "public"."transaction_type_enum" AS ENUM('BUY', 'SELL', 'DIVIDEND', 'AIRDROP', 'FEE');--> statement-breakpoint
CREATE TABLE "transactions" (
"id" uuid PRIMARY KEY NOT NULL,
"asset_id" uuid NOT NULL,
"tx_type" "transaction_type_enum" NOT NULL,
"quantity" numeric(36, 18) NOT NULL,
"price" numeric(36, 18) NOT NULL,
"fee" numeric(36, 18) DEFAULT '0' NOT NULL,
"tx_currency" varchar(10) NOT NULL,
"exchange_rate" numeric(20, 8) DEFAULT '1' NOT NULL,
"executed_at" timestamp with time zone NOT NULL,
"created_at" timestamp with time zone DEFAULT now()
);
--> statement-breakpoint
ALTER TABLE "transactions" ADD CONSTRAINT "transactions_asset_id_assets_id_fk" FOREIGN KEY ("asset_id") REFERENCES "public"."assets"("id") ON DELETE no action ON UPDATE no action;