Migrated sources from mariadb to sqlite

This commit is contained in:
2026-05-08 13:07:47 +02:00
parent 08c9f4b8b0
commit 41aea49762
6 changed files with 54 additions and 89 deletions

View File

@@ -40,17 +40,18 @@
<artifactId>quarkus-hibernate-orm-panache</artifactId> <artifactId>quarkus-hibernate-orm-panache</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.quarkus</groupId> <groupId>org.xerial</groupId>
<artifactId>quarkus-jdbc-mariadb</artifactId> <artifactId>sqlite-jdbc</artifactId>
<version>3.47.1.0</version>
</dependency>
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-community-dialects</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.quarkus</groupId> <groupId>io.quarkus</groupId>
<artifactId>quarkus-flyway</artifactId> <artifactId>quarkus-flyway</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-mysql</artifactId>
</dependency>
<dependency> <dependency>
<groupId>io.quarkus</groupId> <groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId> <artifactId>quarkus-arc</artifactId>

View File

@@ -1,19 +1,23 @@
# Datasource # Datasource SQLite
quarkus.datasource.db-kind=mariadb quarkus.datasource.db-kind=other
quarkus.datasource.username=strichliste quarkus.datasource.jdbc.driver=org.sqlite.JDBC
quarkus.datasource.password=strichliste quarkus.datasource.jdbc.url=jdbc:sqlite:${DB_PATH:/data/qaffee.db}
quarkus.datasource.jdbc.url=jdbc:mariadb://localhost:3306/strichliste
# Agroal connection pool evict stale connections after a DB restart # Connection Pool (SQLite: single writer)
quarkus.datasource.jdbc.background-validation-interval=30S quarkus.datasource.jdbc.min-size=1
quarkus.datasource.jdbc.idle-removal-interval=5M quarkus.datasource.jdbc.max-size=1
quarkus.datasource.jdbc.max-lifetime=10M
# Hibernate # Hibernate
quarkus.hibernate-orm.dialect=org.hibernate.community.dialect.SQLiteDialect
quarkus.hibernate-orm.database.generation=none quarkus.hibernate-orm.database.generation=none
# Flyway # Flyway
quarkus.flyway.migrate-at-start=true quarkus.flyway.migrate-at-start=true
# Baseline: treat V1-V4 as already applied when no history table exists (post-migration start)
quarkus.flyway.baseline-on-migrate=true
quarkus.flyway.baseline-version=4
# Checksums der MariaDB-Dateien passen nicht mehr zu den SQLite-kompatiblen Versionen
quarkus.flyway.validate-on-migrate=false
# CORS ist deaktiviert, da alle Anfragen über den SvelteKit-Proxy laufen # CORS ist deaktiviert, da alle Anfragen über den SvelteKit-Proxy laufen
quarkus.http.cors=false quarkus.http.cors=false

View File

@@ -1,49 +1,50 @@
CREATE TABLE company ( CREATE TABLE company (
id BIGINT AUTO_INCREMENT PRIMARY KEY, id INTEGER PRIMARY KEY,
name VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL,
active BOOLEAN NOT NULL DEFAULT TRUE, active TINYINT(1) NOT NULL DEFAULT 1,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; );
CREATE TABLE employee ( CREATE TABLE employee (
id BIGINT AUTO_INCREMENT PRIMARY KEY, id INTEGER PRIMARY KEY,
company_id BIGINT NOT NULL, company_id BIGINT NOT NULL,
first_name VARCHAR(255) NOT NULL, first_name VARCHAR(255) NOT NULL,
last_name VARCHAR(255) NOT NULL, last_name VARCHAR(255) NOT NULL,
active BOOLEAN NOT NULL DEFAULT TRUE, active TINYINT(1) NOT NULL DEFAULT 1,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT fk_employee_company FOREIGN KEY (company_id) REFERENCES company(id) FOREIGN KEY (company_id) REFERENCES company(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; );
CREATE TABLE product ( CREATE TABLE product (
id BIGINT AUTO_INCREMENT PRIMARY KEY, id INTEGER PRIMARY KEY,
name VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL,
price_cents INT NOT NULL DEFAULT 0, price_cents INT NOT NULL DEFAULT 0,
icon_placeholder VARCHAR(50) DEFAULT 'coffee', icon_placeholder VARCHAR(255) DEFAULT 'coffee',
active BOOLEAN NOT NULL DEFAULT TRUE, active TINYINT(1) NOT NULL DEFAULT 1,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; );
CREATE TABLE tally_entry ( CREATE TABLE tally_entry (
id BIGINT AUTO_INCREMENT PRIMARY KEY, id INTEGER PRIMARY KEY,
employee_id BIGINT NOT NULL, employee_id BIGINT NOT NULL,
product_id BIGINT NOT NULL, product_id BIGINT NOT NULL,
month_key VARCHAR(7) NOT NULL, month_key VARCHAR(7) NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT fk_tally_employee FOREIGN KEY (employee_id) REFERENCES employee(id), FOREIGN KEY (employee_id) REFERENCES employee(id),
CONSTRAINT fk_tally_product FOREIGN KEY (product_id) REFERENCES product(id), FOREIGN KEY (product_id) REFERENCES product(id)
INDEX idx_tally_month (month_key), );
INDEX idx_tally_employee_month (employee_id, month_key)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; CREATE INDEX idx_tally_month ON tally_entry(month_key);
CREATE INDEX idx_tally_employee_month ON tally_entry(employee_id, month_key);
CREATE TABLE access_link ( CREATE TABLE access_link (
id BIGINT AUTO_INCREMENT PRIMARY KEY, id INTEGER PRIMARY KEY,
token VARCHAR(64) NOT NULL UNIQUE, token VARCHAR(64) NOT NULL UNIQUE,
role VARCHAR(20) NOT NULL, role VARCHAR(50) NOT NULL,
company_id BIGINT, company_id BIGINT,
description VARCHAR(255), description TEXT,
active BOOLEAN NOT NULL DEFAULT TRUE, active TINYINT(1) NOT NULL DEFAULT 1,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT fk_access_link_company FOREIGN KEY (company_id) REFERENCES company(id), FOREIGN KEY (company_id) REFERENCES company(id),
CONSTRAINT chk_role CHECK (role IN ('COMPANY_ADMIN', 'PROVIDER_ADMIN')) CHECK (role IN ('COMPANY_ADMIN', 'PROVIDER_ADMIN'))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; );

View File

@@ -1,2 +1,2 @@
ALTER TABLE company ADD COLUMN logo MEDIUMBLOB; ALTER TABLE company ADD COLUMN logo MEDIUMBLOB;
ALTER TABLE company ADD COLUMN logo_content_type VARCHAR(50); ALTER TABLE company ADD COLUMN logo_content_type VARCHAR(255);

BIN
data/qaffee.db Normal file

Binary file not shown.

View File

@@ -1,34 +1,12 @@
version: "3" version: "3"
volumes:
db-data:
services: services:
db:
image: mariadb:11.4.4
container_name: qaffee-db
restart: always
command: --log-warnings=3
environment:
- "MARIADB_ROOT_PASSWORD=rootpassword"
- "MARIADB_DATABASE=strichliste"
- "MARIADB_USER=strichliste"
- "MARIADB_PASSWORD=strichliste"
volumes:
- db-data:/var/lib/mysql
healthcheck:
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
interval: 10s
timeout: 5s
retries: 5
networks:
- traefik-net
backend: backend:
build: ./backend build: ./backend
container_name: qaffee-backend container_name: qaffee-backend
environment: environment:
- "QUARKUS_DATASOURCE_JDBC_URL=jdbc:mariadb://db:3306/strichliste"
- "QUARKUS_DATASOURCE_USERNAME=strichliste"
- "QUARKUS_DATASOURCE_PASSWORD=strichliste"
- "QUARKUS_HTTP_CORS_ORIGINS=https://qaffee.cloud.aquantico.de" - "QUARKUS_HTTP_CORS_ORIGINS=https://qaffee.cloud.aquantico.de"
volumes:
- ./data:/data
labels: labels:
traefik.enable: "true" traefik.enable: "true"
traefik.docker.network: "traefik-net" traefik.docker.network: "traefik-net"
@@ -37,9 +15,6 @@ services:
traefik.http.routers.qaffee-backend.tls: "true" traefik.http.routers.qaffee-backend.tls: "true"
traefik.http.routers.qaffee-backend.tls.certresolver: "myresolver" traefik.http.routers.qaffee-backend.tls.certresolver: "myresolver"
traefik.http.services.qaffee-backend.loadbalancer.server.port: 8080 traefik.http.services.qaffee-backend.loadbalancer.server.port: 8080
depends_on:
db:
condition: service_healthy
networks: networks:
- traefik-net - traefik-net
frontend: frontend:
@@ -61,22 +36,6 @@ services:
- backend - backend
networks: networks:
- traefik-net - traefik-net
backup:
image: mariadb:11.4.4
container_name: qaffee-backup
environment:
- "MARIADB_HOST=db"
- "MARIADB_USER=strichliste"
- "MARIADB_PASSWORD=strichliste"
volumes:
- ./backups:/backups
- ./db/backup.sh:/backup.sh
entrypoint: ["/bin/bash", "/backup.sh"]
depends_on:
db:
condition: service_healthy
networks:
- traefik-net
networks: networks:
traefik-net: traefik-net:
external: false external: false