10 lines
567 B
SQL
10 lines
567 B
SQL
CREATE TABLE "asset_prices_history" (
|
|
"id" uuid PRIMARY KEY NOT NULL,
|
|
"asset_id" uuid NOT NULL,
|
|
"price" numeric(36, 18) NOT NULL,
|
|
"date" date NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
ALTER TABLE "asset_prices_history" ADD CONSTRAINT "asset_prices_history_asset_id_assets_id_fk" FOREIGN KEY ("asset_id") REFERENCES "public"."assets"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
CREATE UNIQUE INDEX "asset_price_date_idx" ON "asset_prices_history" USING btree ("asset_id","date"); |