Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database migrations fail to apply automatically #2420

Closed
hackdna opened this issue Dec 8, 2017 · 6 comments
Closed

Database migrations fail to apply automatically #2420

hackdna opened this issue Dec 8, 2017 · 6 comments

Comments

@hackdna
Copy link
Member

hackdna commented Dec 8, 2017

  • Specific code commit: 775728
  • Version of the web browser and OS: N/A
  • Environment where the error occurred: any

Steps to reproduce

(refinery-platform)vagrant@refinery:/vagrant/refinery$ ./manage.py migrate --noinput

Observed behavior

Operations to perform:
  Synchronize unmigrated apps: djangular, visualization_manager, chunked_upload, rest_framework_swagger, flatblocks, django_markwhat, registration, django_extensions, workflow_manager, rest_framework, haystack
  Apply all migrations: core, annotation_server, sessions, admin, data_set_manager, djcelery, sites, auth, tastypie, galaxy_connector, contenttypes, file_server, tool_manager, file_store, guardian, httpproxy, analysis_manager
Synchronizing apps without migrations:
  Creating tables...
  Installing custom SQL...
  Installing indexes...
Running migrations:
  No migrations to apply.
  Your models have changes that are not yet reflected in a migration, and so won't be applied.
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.

Expected behavior

Migrations should apply automatically.

Notes

Additional information displayed when running the migrate command without the --noinput:

The following content types are stale and need to be deleted:

    core | workflowfilesdl

Any objects related to these content types by a foreign key will also
be deleted. Are you sure you want to delete these content types?
If you're unsure, answer 'no'.

    Type 'yes' to continue, or 'no' to cancel:
@hackdna hackdna added this to the Release 1.6.2 milestone Dec 8, 2017
@hackdna hackdna changed the title Database migrations failing to apply automatically Database migrations fail to apply automatically Dec 8, 2017
@scottx611x
Copy link
Member

scottx611x commented Dec 8, 2017

@hackdna I'm fairly sure the migration applies. You can check with /manage.py migrate --list | grep 0013_auto_20171117_1058

We'll always have stale content types if we're suppressing user input. I'm not sure if newer Django versions have taken care of this.

As for:

Your models have changes that are not yet reflected in a migration, and so won't be applied.
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.

That seems unrelated to this with the migrations created all being related to UUIDFields

(refinery-platform)vagrant@refinery:/vagrant/refinery$ ./manage.py makemigrations
Migrations for 'core':
  0014_auto_20171208_1634.py:
    - Alter field analysis_uuid on analysisresult
    - Alter field file_store_uuid on analysisresult
    - Alter field data_uuid on workflowdatainputmap
Migrations for 'analysis_manager':
  0004_auto_20171208_1634.py:
    - Alter field galaxy_export_task_group_id on analysisstatus
    - Alter field galaxy_import_task_group_id on analysisstatus
    - Alter field galaxy_workflow_task_group_id on analysisstatus
    - Alter field refinery_import_task_group_id on analysisstatus
Migrations for 'file_store':
  0006_auto_20171208_1634.py:
    - Alter field import_task_id on filestoreitem
Migrations for 'data_set_manager':
  0004_auto_20171208_1634.py:
    - Alter field node_analysis_uuid on annotatednode
    - Alter field isarchive_file on investigation
    - Alter field pre_isarchive_file on investigation
    - Alter field analysis_uuid on node
    - Alter field file_uuid on node

Probably related to 811e1d7

@hackdna
Copy link
Member Author

hackdna commented Dec 11, 2017

It looks like it is possible to remove stale content types in a migration using update_contenttypes management command. So, it should be added to core/migrations/0013_auto_20171117_1058.py.

@scottx611x
Copy link
Member

scottx611x commented Dec 12, 2017

@hackdna To me it looks like we couldn't utilize that code without manual intervention.

ok_to_delete can't be == 'yes' here without a users input.

@hackdna
Copy link
Member Author

hackdna commented Dec 12, 2017

OK, in that case, a note about running migrations interactively should be added to the release changelog.
Here is the result of running migrations on a test instance running 21682e2 with the latest data snapshots:

(refinery-platform)ubuntu@ip-172-31-49-47:/srv/refinery-platform/refinery$ ./manage.py migrate
Operations to perform:
  Synchronize unmigrated apps: djangular, visualization_manager, chunked_upload, rest_framework_swagger, flatblocks, django_markwhat, registration, workflow_manager, rest_framework, haystack
  Apply all migrations: core, annotation_server, sessions, admin, data_set_manager, djcelery, sites, auth, tastypie, galaxy_connector, contenttypes, file_server, tool_manager, file_store, guardian, httpproxy, analysis_manager
Synchronizing apps without migrations:
  Creating tables...
  Installing custom SQL...
  Installing indexes...
Running migrations:
  No migrations to apply.
The following content types are stale and need to be deleted:

    core | workflowfilesdl
    core | nodeset
    core | nodegroup
    core | noderelationship
    core | nodepair

Any objects related to these content types by a foreign key will also
be deleted. Are you sure you want to delete these content types?
If you're unsure, answer 'no'.

    Type 'yes' to continue, or 'no' to cancel: yes
The following content types are stale and need to be deleted:

    tool_manager | outputfile

Any objects related to these content types by a foreign key will also
be deleted. Are you sure you want to delete these content types?
If you're unsure, answer 'no'.

    Type 'yes' to continue, or 'no' to cancel: yes

So, this note should have been added to several previous releases where models where deleted.

@scottx611x
Copy link
Member

@hackdna Okay I can go ahead and add notes to past releases that have included the deletion of these models, and close this after I'm done.

@scottx611x
Copy link
Member

I've update Releases v1.6.1 & v1.5.7 accordingly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants