BEGIN; ALTER TABLE posts ADD COLUMN IF NOT EXISTS archived boolean NOT NULL DEFAULT false; ALTER TABLE posts ADD COLUMN IF NOT EXISTS archived_at timestamptz; CREATE INDEX IF NOT EXISTS posts_active_timeline ON posts(created_at DESC,id DESC) WHERE NOT archived; INSERT INTO schema_migrations(version) VALUES('011_post_archiving') ON CONFLICT DO NOTHING; COMMIT;