sql
Runs statements of the engine the installation runs on, written in the step or in files next to the migration.
A step of a YAML migration with type: sql. The class expMigrationStepSql (kernel/classes/migration/steps/expmigrationstepsql.php) is registered in settings/migration.ini [StepSettings] StepTypeList[sql].
Keys
| Key | Type | Default | What it is |
|---|---|---|---|
sql | string | statements for every SQL engine (MySQL/MariaDB, PostgreSQL, SQLite, Oracle) | |
mysql | string | statements for MySQL/MariaDB (win over sql) | |
postgresql | string | statements for PostgreSQL (win over sql) | |
sqlite | string | statements for SQLite (win over sql) | |
oracle | string | statements for Oracle (win over sql) | |
mongodb | list | commands for MongoDB: insert, update, delete, create_collection, drop_collection, create_index, drop_index | |
file | string | a file next to the migration; the engine's own file (<name>.<engine>.sql, <name>.mongodb.json) wins over <name>.sql | |
part | string: up, down | "up" | the part of the file: up, or down (after a line "-- down") |
missing | string: fail, skip | "fail" | what happens on an engine with no statements: fail or skip |
Besides these, every step takes the keys of the engine: type, mode, if, references, environments, engines and comment (the file format). A key of type identifier names a node, an object or another part of the installation by id, remote id, path or name (identifiers).
Values for references
references: { <name>: <value> } keeps a value of the step's result as ${ref.<name>} for the steps and migrations after it:
| Value | What it is |
|---|---|
statements | how many statements or commands ran |
engine | the engine they ran on |
Undoing
A step of this type does not undo itself: a migration with it needs down: or a rollback to its caption.
It touches no cache.
Example
- type: sql
sql: "UPDATE ezcontentclass SET always_available = 1 WHERE identifier = 'news';"
mongodb:
- { update: ezcontentclass, filter: { identifier: news }, set: { always_available: 1 } }Related
Generated by ./console exp:help:examples from settings/migration.ini, kernel/classes/migration/steps/expmigrationstepsql.php. Do not edit this page: change the source and generate again (how). Free documentation: GFDL 1.3 or later.