migration-patterns
Installation
SKILL.md
Migration Patterns
ALTER TABLE Operations
- Add column:
ALTER TABLE t ADD COLUMN col Type [DEFAULT expr] [AFTER existing_col] - Drop column:
ALTER TABLE t DROP COLUMN col - Modify type:
ALTER TABLE t MODIFY COLUMN col NewType(must be compatible) - Rename:
ALTER TABLE t RENAME COLUMN old TO new - These are metadata-only operations — instant for most changes
Engine Changes
- Cannot ALTER engine directly
- Pattern: create new table → insert from old → rename
CREATE TABLE t_new ENGINE = ReplacingMergeTree() ORDER BY id AS SELECT * FROM t_old;
RENAME TABLE t_old TO t_backup, t_new TO t_old;
- For large tables: use
INSERT INTO ... SELECTwith batching