-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
**/bin | ||
.idea | ||
.env | ||
flyway.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Database setup | ||
|
||
```postgresql | ||
CREATE ROLE vahter_bot_ban_service WITH LOGIN PASSWORD 'vahter_bot_ban_service'; | ||
GRANT vahter_bot_ban_service TO postgres; | ||
CREATE DATABASE vahter_bot_ban OWNER vahter_bot_ban_service ENCODING 'UTF8'; | ||
GRANT ALL ON DATABASE vahter_bot_ban TO vahter_bot_ban_service; | ||
GRANT USAGE, CREATE ON SCHEMA public TO vahter_bot_ban_service; | ||
CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; | ||
``` | ||
|
||
Run migrations | ||
|
||
``` | ||
flyway -configFiles=flyway.local.conf migrate | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
flyway.locations=filesystem:./src/migrations | ||
flyway.url=jdbc:postgresql://localhost:5433/vahter_bot_ban | ||
flyway.schemas=public | ||
flyway.user=vahter_bot_ban_service | ||
flyway.password=vahter_bot_ban_service | ||
flyway.baselineOnMigrate=true | ||
flyway.baselineVersion=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
CREATE TABLE "user" | ||
( | ||
id BIGINT NOT NULL | ||
PRIMARY KEY, | ||
username TEXT NULL, | ||
|
||
banned_by BIGINT NULL | ||
CONSTRAINT user_banned_by_fkey | ||
REFERENCES "user" (id), | ||
banned_at TIMESTAMPTZ NULL, | ||
ban_reason TEXT NULL, | ||
|
||
created_at TIMESTAMPTZ NOT NULL DEFAULT timezone('utc'::TEXT, NOW()), | ||
updated_at TIMESTAMPTZ NOT NULL DEFAULT timezone('utc'::TEXT, NOW()) | ||
); | ||
|
||
CREATE UNIQUE INDEX "user_username_uindex" | ||
ON "user" (username); | ||
|
||
CREATE INDEX "user_banned_by_index" | ||
ON "user" (banned_by); | ||
|
||
CREATE TABLE "message" | ||
( | ||
id INT NOT NULL PRIMARY KEY, | ||
user_id BIGINT NOT NULL | ||
CONSTRAINT message_user_id_fkey | ||
REFERENCES "user" (id) | ||
ON DELETE CASCADE, | ||
|
||
created_at TIMESTAMPTZ NOT NULL DEFAULT timezone('utc'::TEXT, NOW()) | ||
); | ||
|
||
CREATE INDEX "message_user_id_index" | ||
ON "message" (user_id); |