Skip to content

Commit

Permalink
Change migration to emit a warning if data exists
Browse files Browse the repository at this point in the history
If there is related data, it is not deleted but the user is given a
warning to allow them to migrate to ckanext-showcase and how to manually
delete the tables.
  • Loading branch information
rossjones committed Dec 23, 2015
1 parent 340d5bc commit e225985
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions ckan/migration/versions/083_remove_related_items.py
@@ -1,5 +1,24 @@

WARNING = """
WARNING: The 'related' tables were not deleted as they currently contain data.
Once you have archived the existing data or migrated the data to
ckanext-showcase, you can safely delete the 'related' and 'related_dataset'
tables using:
psql ckan_default -c 'BEGIN; DROP TABLE related_dataset; \\
DROP TABLE related; COMMIT;'
"""


def upgrade(migrate_engine):
existing = migrate_engine.execute("SELECT COUNT(*) FROM related;")\
.fetchone()
if existing[0] > 0:
print WARNING
return

migrate_engine.execute('''
BEGIN;
DROP TABLE related_dataset;
Expand Down

0 comments on commit e225985

Please sign in to comment.