diff options
| author | ilotterytea <iltsu@alright.party> | 2024-12-14 00:10:40 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2024-12-14 00:10:40 +0500 |
| commit | dbb795b2c851e23d7af2de3983138dcd66d6104c (patch) | |
| tree | 6783aab6b97c43883561d038f1b31cc7db91f8f5 | |
| parent | 2d40d39264de4eed0bdb9e8e0117a8c1e2f199d3 (diff) | |
fix: sql fixes
| -rw-r--r-- | bot/src/modules/notify.hpp | 2 | ||||
| -rw-r--r-- | migrations/2024-05-11T02-53-05_init/up.sql | 20 |
2 files changed, 11 insertions, 11 deletions
diff --git a/bot/src/modules/notify.hpp b/bot/src/modules/notify.hpp index 35b4d36..7bea6a6 100644 --- a/bot/src/modules/notify.hpp +++ b/bot/src/modules/notify.hpp @@ -100,7 +100,7 @@ namespace bot { work.exec( "INSERT INTO event_subscriptions(event_id, user_id) VALUES (" + std::to_string(event[0].as<int>()) + ", " + - std::to_string(request.user.get_id())); + std::to_string(request.user.get_id()) + ")"); work.commit(); return command::Response( diff --git a/migrations/2024-05-11T02-53-05_init/up.sql b/migrations/2024-05-11T02-53-05_init/up.sql index c50562f..1a23ff9 100644 --- a/migrations/2024-05-11T02-53-05_init/up.sql +++ b/migrations/2024-05-11T02-53-05_init/up.sql @@ -16,15 +16,15 @@ CREATE TABLE IF NOT EXISTS "users" ( ); CREATE TABLE IF NOT EXISTS "channel_preferences" ( - "channel_id" INTEGER NOT NULL UNIQUE PRIMARY KEY REFERENCES "channels"("id"), + "channel_id" INTEGER NOT NULL UNIQUE PRIMARY KEY REFERENCES "channels"("id") ON DELETE CASCADE, "prefix" VARCHAR, "locale" VARCHAR ); CREATE TABLE IF NOT EXISTS "user_rights" ( "id" SERIAL NOT NULL UNIQUE PRIMARY KEY, - "user_id" INTEGER NOT NULL REFERENCES "users"("id"), - "channel_id" INTEGER NOT NULL REFERENCES "channels"("id"), + "user_id" INTEGER NOT NULL REFERENCES "users"("id") ON DELETE CASCADE, + "channel_id" INTEGER NOT NULL REFERENCES "channels"("id") ON DELETE CASCADE, "level" INTEGER NOT NULL DEFAULT 1, CONSTRAINT "unique_user_channel" UNIQUE ("user_id", "channel_id") @@ -32,8 +32,8 @@ CREATE TABLE IF NOT EXISTS "user_rights" ( CREATE TABLE IF NOT EXISTS "actions" ( "id" SERIAL NOT NULL UNIQUE PRIMARY KEY, - "user_id" INTEGER NOT NULL REFERENCES "users"("id"), - "channel_id" INTEGER NOT NULL REFERENCES "channels"("id"), + "user_id" INTEGER NOT NULL REFERENCES "users"("id") ON DELETE CASCADE, + "channel_id" INTEGER NOT NULL REFERENCES "channels"("id") ON DELETE CASCADE, "command" VARCHAR NOT NULL, "arguments" VARCHAR, "full_message" VARCHAR NOT NULL, @@ -42,7 +42,7 @@ CREATE TABLE IF NOT EXISTS "actions" ( CREATE TABLE IF NOT EXISTS "events" ( "id" SERIAL NOT NULL UNIQUE PRIMARY KEY, - "channel_id" INTEGER NOT NULL REFERENCES "channels"("id"), + "channel_id" INTEGER NOT NULL REFERENCES "channels"("id") ON DELETE CASCADE, "target_alias_id" INTEGER, "custom_alias_id" VARCHAR, "event_type" INTEGER NOT NULL, @@ -55,20 +55,20 @@ CREATE TABLE IF NOT EXISTS "events" ( CREATE TABLE IF NOT EXISTS "event_subscriptions" ( "id" SERIAL NOT NULL UNIQUE PRIMARY KEY, - "event_id" INTEGER NOT NULL REFERENCES "events"("id"), - "user_id" INTEGER NOT NULL REFERENCES "users"("id") + "event_id" INTEGER NOT NULL REFERENCES "events"("id") ON DELETE CASCADE, + "user_id" INTEGER NOT NULL REFERENCES "users"("id") ON DELETE CASCADE ); CREATE TABLE IF NOT EXISTS "custom_commands" ( "id" SERIAL NOT NULL UNIQUE PRIMARY KEY, - "channel_id" INTEGER NOT NULL REFERENCES "channels"("id"), + "channel_id" INTEGER NOT NULL REFERENCES "channels"("id") ON DELETE CASCADE, "name" VARCHAR NOT NULL, "message" VARCHAR NOT NULL ); CREATE TABLE IF NOT EXISTS "timers" ( "id" SERIAL NOT NULL UNIQUE PRIMARY KEY, - "channel_id" INTEGER NOT NULL REFERENCES "channels"("id"), + "channel_id" INTEGER NOT NULL REFERENCES "channels"("id") ON DELETE CASCADE, "name" VARCHAR NOT NULL, "message" VARCHAR NOT NULL, "interval_sec" INTEGER NOT NULL, |
