| author | Thorsten Ortlepp
<post@ortlepp.ms> 2025-12-03 22:28:02 UTC |
| committer | Thorsten Ortlepp
<post@ortlepp.ms> 2025-12-03 22:28:02 UTC |
| parent | f9d76a0d9516b48b5a01408b26ec84e0d191ead1 |
| README.md | +16 | -0 |
| src/main/resources/application.properties | +3 | -0 |
| src/main/resources/db/migration/V1_0__create_tables.sql | +18 | -0 |
diff --git a/README.md b/README.md new file mode 100644 index 0000000..07578d2 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# Subscription-Tool + +A Spring Boot tool to manage subscriptions (e.g. to a newsletter). + +## Setup + +### Database + +A PostgreSQL database is required to run the application. To set up a local database, you can use +Docker: + +``` +docker run --name dev-subscriptiontool -e POSTGRES_PASSWORD=PASSWORD -p 5000:5432 -d postgres +docker exec -it dev-subscriptiontool psql -U postgres +CREATE DATABASE subscriptiontool; +``` diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 2d5293a..2f3b62e 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1 +1,4 @@ spring.application.name=subscription-tool +spring.datasource.url=jdbc:postgresql://localhost:5000/subscriptiontool +spring.datasource.username=postgres +spring.datasource.password=PASSWORD diff --git a/src/main/resources/db/migration/V1_0__create_tables.sql b/src/main/resources/db/migration/V1_0__create_tables.sql new file mode 100644 index 0000000..8ba8387 --- /dev/null +++ b/src/main/resources/db/migration/V1_0__create_tables.sql @@ -0,0 +1,18 @@ +CREATE TABLE subscriptions +( + id BIGINT GENERATED ALWAYS AS IDENTITY UNIQUE, + mail VARCHAR(255) NOT NULL UNIQUE, + code CHAR(64) NOT NULL, + confirmed BOOLEAN NOT NULL DEFAULT FALSE, + registration TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + confirmation TIMESTAMP +); + +CREATE TABLE mailqueue +( + id BIGINT GENERATED ALWAYS AS IDENTITY UNIQUE, + subscription BIGINT REFERENCES subscriptions (id), + sent BOOLEAN NOT NULL DEFAULT FALSE, + creation TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + completion TIMESTAMP +);