-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.sql
42 lines (41 loc) · 1.27 KB
/
script.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
34
35
36
37
38
39
40
41
42
BEGIN;
/*
* Copyright (c) 2024.
* Julio Cezar Riffel
* https://www.linkedin.com/in/julio-cezar-riffel/
* https://github.com/julioriffel
*
*/
--
-- Create model Cliente
--
CREATE UNLOGGED TABLE "conta_corrente_cliente"
(
"id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
"limite" integer NOT NULL
);
--
-- Create model Transacao
--
CREATE UNLOGGED TABLE "conta_corrente_transacao"
(
"id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
"tipo" varchar(1) NOT NULL,
"valor" integer NOT NULL,
"descricao" varchar(10) NOT NULL,
"realizada_em" timestamp with time zone NOT NULL,
"cliente_id" bigint NOT NULL
);
--
-- Raw SQL operation
--
INSERT INTO conta_corrente_cliente (id, limite)
VALUES (1, 100000),
(2, 80000),
(3, 1000000),
(4, 10000000),
(5, 500000);
-- ALTER TABLE "conta_corrente_transacao"
-- ADD CONSTRAINT "conta_corrente_trans_cliente_id_2ee27b48_fk_conta_cor" FOREIGN KEY ("cliente_id") REFERENCES "conta_corrente_cliente" ("id") DEFERRABLE INITIALLY DEFERRED;
CREATE INDEX "conta_corrente_transacao_cliente_id_2ee27b48" ON "conta_corrente_transacao" ("cliente_id");
COMMIT;