1479208987 | current | ||
---|---|---|---|
Line 358: | Line 358: | ||
WHERE PAGEEXISTS(pageid) = 1 | WHERE PAGEEXISTS(pageid) = 1 | ||
</code> | </code> | ||
+ | |||
+ | ==== Events ==== | ||
+ | |||
+ | === PLUGIN_SQLITE_DATABASE_UPGRADE === | ||
+ | |||
+ | This event is triggered when a new migration (see above) is applied. This makes it possible to do more complex migrations that require more than just SQL. | ||
+ | |||
+ | The provided data looks like this: | ||
+ | |||
+ | <code php> | ||
+ | $data = array( | ||
+ | 'from' => 5, // previous version | ||
+ | 'to' => 6, // version this migration migrates to | ||
+ | 'file' => /some/path/to/plugin/db/update0006.sql, // the associated update file | ||
+ | 'sqlite' => $this // the initialized sqlite plugin instance for this database | ||
+ | ); | ||
+ | </code> | ||
+ | |||
+ | |||
+ | The ''BEFORE'' event is executed before the migration file is applied. The default action is to apply that file and increase the ''dbversion'' field in the ''opts'' table. | ||
+ | |||
+ | When an event prevents the default, the proper ''$event->result'' has to be set! When the result is true, the ''dbversion'' is increased and any additional migrations are run. When the result is false, the migration process is aborted. | ||
+ | |||
+ | The ''BEFORE'' event can optionally change the ''file'' attribute of the data to load a different file. | ||
+ | |||
+ | The ''AFTER'' event is only triggered after the migration file has been applied or the ''BEFORE'' event set a truish result. At the ''AFTER'' time, the ''dbversion'' has already been increased. | ||
+ | |||
===== Bugs, Feature Requests and Patches ===== | ===== Bugs, Feature Requests and Patches ===== | ||
Please submit bugs and feature requests in the **[[https://github.com/cosmocode/sqlite/issues|issue tracker]]**. Patches should be sent unified diff format or as git patches. Or even better: fork the repository at github and send a merge request. | Please submit bugs and feature requests in the **[[https://github.com/cosmocode/sqlite/issues|issue tracker]]**. Patches should be sent unified diff format or as git patches. Or even better: fork the repository at github and send a merge request. |
↧
plugin:sqlite
↧