We wish to supply SQL syntax for Online DDL (and possibly align that with VSCHEMA/VINDEX syntax). Right now it is only possible to submit a migration via SQL, but not to track/control it. Tracking/control are possible via vtctl.
In this issue we propose syntax that is SQL/MySQL idiomatic. We need syntax for:
Suggestion 1
SHOW vitess_migrations; -- shows everything
SHOW vitess_migrations LIKE '24213daa_7b26_11eb_b423_f875a4d24e90';
SHOW vitess_migrations WHERE migration_status='failed'; -- single KEY='VALUE'
SHOW vitess_migrations WHERE mysql_table='my_table'; -- single KEY='VALUE'
SHOW vitess_migrations WHERE started_timestamp > NOW() - INTERVAL 7 DAY; -- Too complex?
ALTER vitess_migration '24213daa_7b26_11eb_b423_f875a4d24e90' RETRY;
ALTER vitess_migration '24213daa_7b26_11eb_b423_f875a4d24e90' CANCEL;
ALTER vitess_migration CANCEL ALL;
REVERT vitess_migration '24213daa_7b26_11eb_b423_f875a4d24e90';
Discussion:
- We use similar notations to
SHOW TABLES... and ALTER TABLE.
- The
SHOW commands are mostly generic. Showing the status of a specific migration is more useful than others, hence specialized LIKE syntax.
- For
RETRY/CANCEL we use ALTER because we are, in fact, changing the migration state, or rather controlling it (anecdotally, behind the scenes this is implemented with UPDATE _vt.schema_migrations)
REVERT has its own syntax because:
- It's not an
ALTER of an existing migration: it's the creation of a new migration, with new Job ID, that reverts a previous migration.
- It's such a special and empowering operation that I feel it deserves its own syntax. I'm a salesperson in disguise.
- I think a common query is to show "recent" migrations (
vtctl OnlineDDL commerce show recent). But in the above, implementation for RECENT is cumbersome (WHERE started_timestamp > NOW() - INTERVAL 7 DAY).
Suggestion 2
Use more verbose syntax:
SHOW vitess_migrations WITH STATUS 'running';
SHOW vitess_migrations WITH STATUS 'complete';
SHOW vitess_migrations WITH STATUS 'failed';
SHOW vitess_migrations FOR TABLE 'my_table';
SHOW FAILED vitess_migrations;
SHOW COMPLETE vitess_migrations;
SHOW RECENT vitess_migrations;
In the above we have specialized syntax for showing migrations per filter.
- Each reads better
- We have fine grained control over what can be queried
- Simplified syntax for
RECENT
- But together there's multiple syntax options to remember
Suggestion 3
Less English, more SQL-ish?
SHOW vitess_migrations FAILED;
SHOW vitess_migrations COMPLETE;
SHOW vitess_migrations RECENT;
Like (2), but putting the commands last.
Soliciting opinions
Tracking issue: #6926
cc @vitessio/ps-vitess
We wish to supply SQL syntax for Online DDL (and possibly align that with
VSCHEMA/VINDEXsyntax). Right now it is only possible to submit a migration via SQL, but not to track/control it. Tracking/control are possible viavtctl.In this issue we propose syntax that is SQL/MySQL idiomatic. We need syntax for:
Suggestion 1
Discussion:
SHOW TABLES...andALTER TABLE.SHOWcommands are mostly generic. Showing the status of a specific migration is more useful than others, hence specializedLIKEsyntax.RETRY/CANCELwe useALTERbecause we are, in fact, changing the migration state, or rather controlling it (anecdotally, behind the scenes this is implemented withUPDATE _vt.schema_migrations)REVERThas its own syntax because:ALTERof an existing migration: it's the creation of a new migration, with new Job ID, that reverts a previous migration.vtctl OnlineDDL commerce show recent). But in the above, implementation forRECENTis cumbersome (WHERE started_timestamp > NOW() - INTERVAL 7 DAY).Suggestion 2
Use more verbose syntax:
In the above we have specialized syntax for showing migrations per filter.
RECENTSuggestion 3
Less English, more SQL-ish?
Like (2), but putting the commands last.
Soliciting opinions
Tracking issue: #6926
cc @vitessio/ps-vitess