Skip to content

Commit

Permalink
[#2234] Ignore metadata table on migration
Browse files Browse the repository at this point in the history
  • Loading branch information
amercader committed Oct 22, 2015
1 parent c78329c commit 375c789
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions ckan/migration/versions/081_set_datastore_active.py
Expand Up @@ -20,6 +20,7 @@ def upgrade(migrate_engine):
SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'public'
AND table_name != '_table_metadata'
''')

if resources_in_datastore.rowcount:
Expand All @@ -34,17 +35,20 @@ def upgrade(migrate_engine):
in resources_in_datastore])
)
)

params = []
for resource in resources:
new_extras = json.loads(resource[1])
new_extras.update({'datastore_active': True})
params.append(
{'id': resource[0],
'extras': json.dumps(new_extras)})

migrate_engine.execute(
text('UPDATE resource SET extras = :extras WHERE id = :id'),
params)
if resources.rowcount:
params = []
for resource in resources:
new_extras = json.loads(resource[1])
new_extras.update({'datastore_active': True})
params.append(
{'id': resource[0],
'extras': json.dumps(new_extras)})

migrate_engine.execute(
text('''
UPDATE resource
SET extras = :extras
WHERE id = :id'''),
params)
finally:
datastore_engine.dispose()

0 comments on commit 375c789

Please sign in to comment.