From 2f16b7065aa0c94198824e1b842a6220169972e4 Mon Sep 17 00:00:00 2001 From: Steven Date: Fri, 26 Jan 2024 09:15:27 +0800 Subject: [PATCH] chore: tweak scripts --- .../mysql/migration/prod/0.19/00__add_resource_name.sql | 8 ++++++-- .../sqlite/migration/prod/0.19/00__add_resource_name.sql | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/store/db/mysql/migration/prod/0.19/00__add_resource_name.sql b/store/db/mysql/migration/prod/0.19/00__add_resource_name.sql index b956d0d8..46256914 100644 --- a/store/db/mysql/migration/prod/0.19/00__add_resource_name.sql +++ b/store/db/mysql/migration/prod/0.19/00__add_resource_name.sql @@ -1,11 +1,15 @@ -ALTER TABLE `memo` ADD COLUMN `resource_name` VARCHAR(256) NOT NULL AFTER `id`; +ALTER TABLE `memo` ADD COLUMN `resource_name` VARCHAR(256) AFTER `id`; UPDATE `memo` SET `resource_name` = uuid(); +ALTER TABLE `memo` MODIFY COLUMN `resource_name` VARCHAR(256) NOT NULL; + CREATE UNIQUE INDEX idx_memo_resource_name ON `memo` (`resource_name`); -ALTER TABLE `resource` ADD COLUMN `resource_name` VARCHAR(256) NOT NULL AFTER `id`; +ALTER TABLE `resource` ADD COLUMN `resource_name` VARCHAR(256) AFTER `id`; UPDATE `resource` SET `resource_name` = uuid(); +ALTER TABLE `resource` MODIFY COLUMN `resource_name` VARCHAR(256) NOT NULL; + CREATE UNIQUE INDEX idx_resource_resource_name ON `resource` (`resource_name`); diff --git a/store/db/sqlite/migration/prod/0.19/00__add_resource_name.sql b/store/db/sqlite/migration/prod/0.19/00__add_resource_name.sql index 8f774786..3e39e5e7 100644 --- a/store/db/sqlite/migration/prod/0.19/00__add_resource_name.sql +++ b/store/db/sqlite/migration/prod/0.19/00__add_resource_name.sql @@ -1,10 +1,10 @@ -ALTER TABLE memo ADD COLUMN resource_name TEXT NOT NULL; +ALTER TABLE memo ADD COLUMN resource_name TEXT; UPDATE memo SET resource_name = lower(hex(randomblob(8))); CREATE UNIQUE INDEX idx_memo_resource_name ON memo (resource_name); -ALTER TABLE resource ADD COLUMN resource_name TEXT NOT NULL; +ALTER TABLE resource ADD COLUMN resource_name TEXT; UPDATE resource SET resource_name = lower(hex(randomblob(8)));