#16 Replace HSQLDB with H2

This commit is contained in:
2021-03-04 18:38:02 +01:00
parent 51d491c5d1
commit 4a9af8e563
15 changed files with 22 additions and 27 deletions

View File

@@ -0,0 +1,5 @@
spring.flyway.locations=classpath:/database/h2,classpath:/database/common
# DataSource
spring.datasource.url=jdbc:h2:mem:.;DB_CLOSE_DELAY=-1
spring.datasource.username=sa

View File

@@ -1,6 +0,0 @@
spring.flyway.locations=classpath:/database/hsqldb,classpath:/database/common
# DataSource
#spring.datasource.url=jdbc:hsqldb:file:/tmp/financer
spring.datasource.url=jdbc:hsqldb:mem:.
spring.datasource.username=sa

View File

@@ -1,3 +1,3 @@
UPDATE account SET account_group_id = (SELECT id FROM account_group WHERE name = 'Car') WHERE "key" IN ('Car', 'Gas')
UPDATE account SET account_group_id = (SELECT id FROM account_group WHERE name = 'Car') WHERE "key" IN ('Car', 'Gas');
UPDATE account SET account_group_id = (SELECT id FROM account_group WHERE name = 'Housing') WHERE "key" IN ('Rent', 'FVS', 'Electricity/Water')
UPDATE account SET account_group_id = (SELECT id FROM account_group WHERE name = 'Housing') WHERE "key" IN ('Rent', 'FVS', 'Electricity/Water');

View File

@@ -1,13 +1,13 @@
-- Account group table
CREATE TABLE period (
id BIGINT NOT NULL PRIMARY KEY IDENTITY,
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
type VARCHAR(255) NOT NULL,
start DATETIME NOT NULL,
"end" DATETIME
);
CREATE TABLE link_transaction_period (
id BIGINT NOT NULL PRIMARY KEY IDENTITY,
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
transaction_id BIGINT NOT NULL,
period_id BIGINT NOT NULL,

View File

@@ -1,6 +1,6 @@
-- Account statistic table
CREATE TABLE account_statistic (
id BIGINT NOT NULL PRIMARY KEY IDENTITY,
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
account_id BIGINT NOT NULL,
period_id BIGINT NOT NULL,
spending_total_from BIGINT NOT NULL,

View File

@@ -4,7 +4,7 @@
-- Account table
CREATE TABLE account (
id BIGINT NOT NULL PRIMARY KEY IDENTITY,
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
"key" VARCHAR(1000) NOT NULL, --escape keyword "key"
type VARCHAR(255) NOT NULL,
status VARCHAR(255) NOT NULL,
@@ -15,7 +15,7 @@ CREATE TABLE account (
-- Recurring transaction table
CREATE TABLE recurring_transaction (
id BIGINT NOT NULL PRIMARY KEY IDENTITY,
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
from_account_id BIGINT NOT NULL,
to_account_id BIGINT NOT NULL,
description VARCHAR(1000),
@@ -32,7 +32,7 @@ CREATE TABLE recurring_transaction (
-- Transaction table
CREATE TABLE "transaction" ( --escape keyword "transaction"
id BIGINT NOT NULL PRIMARY KEY IDENTITY,
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
from_account_id BIGINT NOT NULL,
to_account_id BIGINT NOT NULL,
"date" DATE NOT NULL, --escape keyword "date"

View File

@@ -1,11 +1,11 @@
CREATE TABLE file (
id BIGINT NOT NULL PRIMARY KEY IDENTITY,
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
name NVARCHAR(1000) NOT NULL,
content NVARCHAR(4000) NOT NULL
);
CREATE TABLE link_transaction_file (
id BIGINT NOT NULL PRIMARY KEY IDENTITY,
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
transaction_id BIGINT NOT NULL,
file_id BIGINT NOT NULL,

View File

@@ -1,6 +1,6 @@
-- Account group table
CREATE TABLE account_group (
id BIGINT NOT NULL PRIMARY KEY IDENTITY,
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(1000) NOT NULL,
CONSTRAINT un_account_group_name_key UNIQUE (name)

View File

@@ -1,5 +1,5 @@
spring.profiles.active=hsqldb,dev
spring.profiles.active=h2,dev
spring.datasource.url=jdbc:hsqldb:mem:.
spring.datasource.url=jdbc:h2:mem:.;DB_CLOSE_DELAY=-1
spring.datasource.username=sa
spring.flyway.locations=classpath:/database/hsqldb,classpath:/database/hsqldb/integration,classpath:/database/common
spring.flyway.locations=classpath:/database/h2,classpath:/database/h2/integration,classpath:/database/common