Eric Bower
·
03 Aug 22
20220730_post_change_filename_to_slug.sql
1ALTER TABLE posts ADD COLUMN slug character varying(255) NOT NULL DEFAULT '';
2UPDATE posts SET slug = filename;
3UPDATE posts SET filename = '_styles.css' WHERE filename = '_styles' AND cur_space = 'prose';
4UPDATE posts SET filename = filename || '.md' WHERE filename <> '_styles.css' AND cur_space = 'prose';
5UPDATE posts SET filename = filename || '.txt' WHERE cur_space = 'lists';
6ALTER TABLE posts ADD CONSTRAINT unique_slug_for_user UNIQUE (user_id, cur_space, slug);