Migrations

When modifying the schema of a crr:

  1. Be sure you start that modification with a call to crsql_alter_begin
  2. Complete that modification with a call to crsql_alter_commit

calls to crsql_alter_begin and crsql_alter_commit may be nested as well as occur in an outer transaction.

If the alter fails, all levels of transactions and savepoints will be rolled back.

Usage:

SELECT crsql_alter_begin('table_name');
...
SELECT crsql_alter_commit('table_name');

Example:

SELECT crsql_alter_begin('foo');
ALTER TABLE foo ADD COLUMN c TEXT;
SELECT crsql_alter_commit('foo');
SELECT crsql_alter_begin('bar');
ALTER TABLE bar ADD COLUMN baz TEXT;
SELECT crsql_alter_commit('bar');

Currently supported schema alterations:

  1. add columns
  2. drop columns

Support for column renames, table renames, column type modification is a work in progress.