CREATE TYPE stock_logs_type AS ENUM ( 'in', 'out' ); CREATE TABLE stock_logs ( "id" uuid default gen_random_uuid() not null primary key, "index_id" bigserial not null, "merchant_id" uuid references "merchants"("id") not null, "product_id" uuid references "products"("id") not null, "created_by" uuid references "users"("id") not null, "transaction_id" uuid, "transaction_action_type" varchar not null , -- "penjualan / pembelian / pengaturan stok" "transaction_description" varchar not null, "type" stock_logs_type not null, "selling_price" double precision default(0::double precision) NOT NULL, "purchase_price" double precision default(0:: double precision) NOT NULL, "quantity" double precision default(0::double precision) NOT NULL, "created_at" timestamp default(now()), "updated_at" timestamp default(now()) ); CREATE INDEX ON "stock_logs"("index_id");