fix: postgres upgrade script

This commit is contained in:
Steven 2024-05-11 22:35:26 +08:00
parent 087f60ba7b
commit 29a22914cf

View file

@ -1,16 +1,11 @@
ALTER TABLE `resource`
ADD COLUMN `storage_type` VARCHAR(256) NOT NULL DEFAULT '',
ADD COLUMN `reference` VARCHAR(256) NOT NULL DEFAULT '',
ADD COLUMN `payload` TEXT NOT NULL;
ALTER TABLE resource ADD COLUMN storage_type TEXT NOT NULL DEFAULT '';
ALTER TABLE resource ADD COLUMN reference TEXT NOT NULL DEFAULT '';
ALTER TABLE resource ADD COLUMN payload TEXT NOT NULL DEFAULT '{}';
UPDATE `resource`
SET `storage_type` = 'LOCAL', `reference` = `internal_path`
WHERE `internal_path` IS NOT NULL AND `internal_path` != '';
UPDATE resource SET storage_type = 'LOCAL', reference = internal_path WHERE internal_path IS NOT NULL AND internal_path != '';
UPDATE `resource`
SET `storage_type` = 'EXTERNAL', `reference` = `external_link`
WHERE `external_link` IS NOT NULL AND `external_link` != '';
UPDATE resource SET storage_type = 'EXTERNAL', reference = external_link WHERE external_link IS NOT NULL AND external_link != '';
ALTER TABLE `resource` DROP COLUMN `internal_path`;
ALTER TABLE resource DROP COLUMN internal_path;
ALTER TABLE `resource` DROP COLUMN `external_link`;
ALTER TABLE resource DROP COLUMN external_link;