Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow extensions to contain migrations
As currently managing database tables in extensions is rather painful we end up with developers either checking and creating the tables at startup time, or creating paster command specific to their extension which creates tables. Running actual migrations is often problematic. These changes provide a new interface called IMigration that allows an extension to specify where it stored its migrations. These migrations are then run whenever the ```db upgrade``` command is executed. The paster templates for creating a new extension are also updated to automatically created the required files for running migrations.
- Loading branch information
Showing
9 changed files
with
64 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
include README.rst | ||
recursive-include ckanext/{{ project_shortname }} *.html *.json *.js *.less *.css | ||
recursive-include ckanext/{{ project_shortname }}/migrations * |
Empty file.
4 changes: 4 additions & 0 deletions
4
ckan/pastertemplates/template/ckanext/+project_shortname+/migrations/migrate.cfg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[db_settings] | ||
repository_id=ckanext-{{ project_shortname }} | ||
version_table=migrate_version | ||
required_dbs=[] |
7 changes: 7 additions & 0 deletions
7
...emplates/template/ckanext/+project_shortname+/migrations/versions/001_initial_creation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
def upgrade(migrate_engine): | ||
pass | ||
|
||
|
||
def downgrade(migrate_engine): | ||
pass |
Empty file.
10 changes: 9 additions & 1 deletion
10
ckan/pastertemplates/template/ckanext/+project_shortname+/plugin.py_tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters