Add PostgreSQL support
Therefore add migration scripts and default connection settings. Also add a draft chapter in the documentation about how to setup the database . Make HSQLDB the default for integration tests.
This commit is contained in:
45
src/main/resources/database/postgres/V1_0_0__init.sql
Normal file
45
src/main/resources/database/postgres/V1_0_0__init.sql
Normal file
@@ -0,0 +1,45 @@
|
||||
--
|
||||
-- This file contains the basic initialization of the financer schema and basic init data
|
||||
--
|
||||
|
||||
-- Account table
|
||||
CREATE TABLE account (
|
||||
id BIGINT NOT NULL PRIMARY KEY GENERATED ALWAYS AS 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 un_account_name_key UNIQUE ("key")
|
||||
);
|
||||
|
||||
-- Recurring transaction table
|
||||
CREATE TABLE recurring_transaction (
|
||||
id BIGINT NOT NULL PRIMARY KEY GENERATED ALWAYS AS 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_recurring_transaction_from_account FOREIGN KEY (from_account_id) REFERENCES account (id),
|
||||
CONSTRAINT fk_recurring_transaction_to_account FOREIGN KEY (to_account_id) REFERENCES account (id)
|
||||
);
|
||||
|
||||
-- Transaction table
|
||||
CREATE TABLE "transaction" ( --escape keyword "transaction"
|
||||
id BIGINT NOT NULL PRIMARY KEY GENERATED ALWAYS AS 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,
|
||||
recurring_transaction_id BIGINT,
|
||||
|
||||
CONSTRAINT fk_transaction_from_account FOREIGN KEY (from_account_id) REFERENCES account (id),
|
||||
CONSTRAINT fk_transaction_to_account FOREIGN KEY (to_account_id) REFERENCES account (id),
|
||||
CONSTRAINT fk_transaction_recurring_transaction FOREIGN KEY (recurring_transaction_id) REFERENCES recurring_transaction (id)
|
||||
);
|
||||
Reference in New Issue
Block a user