From 2e1382c1d41261c7d82c70a843537777f06fff2c Mon Sep 17 00:00:00 2001 From: Radical Date: Thu, 22 May 2025 16:28:58 +0200 Subject: [PATCH] feat: make channel description nullable --- .../2025-05-21-203022_channel_description_nullable/down.sql | 4 ++++ .../2025-05-21-203022_channel_description_nullable/up.sql | 3 +++ src/schema.rs | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 migrations/2025-05-21-203022_channel_description_nullable/down.sql create mode 100644 migrations/2025-05-21-203022_channel_description_nullable/up.sql diff --git a/migrations/2025-05-21-203022_channel_description_nullable/down.sql b/migrations/2025-05-21-203022_channel_description_nullable/down.sql new file mode 100644 index 0000000..73344b1 --- /dev/null +++ b/migrations/2025-05-21-203022_channel_description_nullable/down.sql @@ -0,0 +1,4 @@ +-- This file should undo anything in `up.sql` +UPDATE channels SET description = '' WHERE description IS NULL; +ALTER TABLE ONLY channels ALTER COLUMN description SET NOT NULL; +ALTER TABLE ONLY channels ALTER COLUMN description DROP DEFAULT; diff --git a/migrations/2025-05-21-203022_channel_description_nullable/up.sql b/migrations/2025-05-21-203022_channel_description_nullable/up.sql new file mode 100644 index 0000000..5ca6776 --- /dev/null +++ b/migrations/2025-05-21-203022_channel_description_nullable/up.sql @@ -0,0 +1,3 @@ +-- Your SQL goes here +ALTER TABLE ONLY channels ALTER COLUMN description DROP NOT NULL; +ALTER TABLE ONLY channels ALTER COLUMN description SET DEFAULT NULL; diff --git a/src/schema.rs b/src/schema.rs index f83018c..b3274fc 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -26,7 +26,7 @@ diesel::table! { #[max_length = 32] name -> Varchar, #[max_length = 500] - description -> Varchar, + description -> Nullable, } }