internal/store/migrations/0058_profile_about_out.up.sql

main
gitbay/internal/store/migrations/0058_profile_about_out.up.sql history · blame · raw

22 lines · 930 bytes

 1-- The about text moves into profile/README.* in <owner>/.gitbay. A SQL
 2-- migration cannot write git objects, so the text is parked here and
 3-- `gitbayd admin migrate-profile-about` drains the table into
 4-- repositories. A later release drops the emptied table.
 5CREATE TABLE profile_about_backfill (
 6  owner_kind   TEXT    NOT NULL,
 7  owner_id     INTEGER NOT NULL,
 8  about        TEXT    NOT NULL,
 9  about_format TEXT    NOT NULL,
10  PRIMARY KEY (owner_kind, owner_id)
11);
12
13INSERT INTO profile_about_backfill (owner_kind, owner_id, about, about_format)
14SELECT 'user', id, about, about_format FROM users WHERE about <> '';
15
16INSERT INTO profile_about_backfill (owner_kind, owner_id, about, about_format)
17SELECT 'org', id, about, about_format FROM orgs WHERE about <> '';
18
19ALTER TABLE users DROP COLUMN about;
20ALTER TABLE users DROP COLUMN about_format;
21ALTER TABLE orgs DROP COLUMN about;
22ALTER TABLE orgs DROP COLUMN about_format;