forked from zanfranceschi/rinha-de-backend-2024-q1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sql
33 lines (27 loc) · 758 Bytes
/
init.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
-- CreateTable
CREATE TABLE "Cliente" (
"id" SERIAL NOT NULL,
"limite" INTEGER NOT NULL,
"saldo" INTEGER NOT NULL,
CONSTRAINT "Cliente_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Transacao" (
"id" SERIAL NOT NULL,
"client_id" INTEGER NOT NULL,
"valor" INTEGER NOT NULL,
"realizada_em" TIMESTAMP(3) NOT NULL,
"descricao" TEXT,
"tipo" TEXT NOT NULL,
CONSTRAINT "Transacao_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "Transacao" ADD CONSTRAINT "Transacao_client_id_fkey" FOREIGN KEY ("client_id") REFERENCES "Cliente"("id") ON DELETE CASCADE ON UPDATE CASCADE;
INSERT INTO "Cliente"
(limite, saldo)
VALUES
(100000, 0),
(80000, 0),
(1000000, 0),
(10000000, 0),
(500000, 0);