Initial commit for financer
This commit is contained in:
55
src/main/resources/database/hsqldb/V1_0_0__init.sql
Normal file
55
src/main/resources/database/hsqldb/V1_0_0__init.sql
Normal file
@@ -0,0 +1,55 @@
|
||||
--
|
||||
-- This file contains the basic initialization of the financer schema and init data
|
||||
--
|
||||
|
||||
-- Account table and init data
|
||||
CREATE TABLE account (
|
||||
id BIGINT NOT NULL PRIMARY KEY IDENTITY,
|
||||
"key" VARCHAR(1000) NOT NULL, --escape keyword "key"
|
||||
type VARCHAR(255) NOT NULL,
|
||||
status VARCHAR(255) NOT NULL,
|
||||
current_balance BIGINT NOT NULL,
|
||||
|
||||
CONSTRAINT c_u_name_key UNIQUE ("key")
|
||||
);
|
||||
|
||||
INSERT INTO account ("key", type, status, current_balance)
|
||||
VALUES ('accounts.checkaccount', 'BANK', 'OPEN', 0);
|
||||
|
||||
INSERT INTO account ("key", type, status, current_balance)
|
||||
VALUES ('accounts.income', 'INCOME', 'OPEN', 0);
|
||||
|
||||
INSERT INTO account ("key", type, status, current_balance)
|
||||
VALUES ('accounts.cash', 'CASH', 'OPEN', 0);
|
||||
|
||||
INSERT INTO account ("key", type, status, current_balance)
|
||||
VALUES ('accounts.start', 'START', 'OPEN', 0);
|
||||
|
||||
-- Transaction table
|
||||
CREATE TABLE "transaction" ( --escape keyword "transaction"
|
||||
id BIGINT NOT NULL PRIMARY KEY IDENTITY,
|
||||
from_account_id BIGINT NOT NULL,
|
||||
to_account_id BIGINT NOT NULL,
|
||||
"date" DATE NOT NULL, --escape keyword "date"
|
||||
description VARCHAR(1000),
|
||||
amount BIGINT NOT NULL,
|
||||
|
||||
CONSTRAINT fk_from_account FOREIGN KEY (from_account_id) REFERENCES account (id),
|
||||
CONSTRAINT fk_to_account FOREIGN KEY (to_account_id) REFERENCES account (id)
|
||||
);
|
||||
|
||||
-- Transaction table
|
||||
CREATE TABLE recurring_transaction (
|
||||
id BIGINT NOT NULL PRIMARY KEY IDENTITY,
|
||||
from_account_id BIGINT NOT NULL,
|
||||
to_account_id BIGINT NOT NULL,
|
||||
description VARCHAR(1000),
|
||||
amount BIGINT NOT NULL,
|
||||
interval_type VARCHAR(255) NOT NULL,
|
||||
first_occurrence DATE NOT NULL,
|
||||
last_occurrence DATE,
|
||||
holiday_weekend_type VARCHAR(255) NOT NULL,
|
||||
|
||||
CONSTRAINT fk_from_account FOREIGN KEY (from_account_id) REFERENCES account (id),
|
||||
CONSTRAINT fk_to_account FOREIGN KEY (to_account_id) REFERENCES account (id)
|
||||
);
|
||||
Reference in New Issue
Block a user