osf.io icon indicating copy to clipboard operation
osf.io copied to clipboard

[ENG-969] Spruce up UserEducation and UserEmployment migration

Open Johnetordoff opened this issue 5 years ago • 1 comments

⚠️ Remeber to add TEST_MIGRATION to your local.py and set the value to true to unit test.

Purpose

Have working migrations for UserEducation and UserEmployment models.

Changes

  • add migrations to add UserEducation and UserEmployment models
  • add management command to populate those models

QA Notes

I did this from an old staging dump forgive me if it's not up to date/ properly benchmarked, it took about 2 seconds for 1667 rows of user.

No user facing changes

Documentation

migration, no docs.

Side Effects

None that I know of.

Ticket

https://openscience.atlassian.net/browse/ENG-969

Johnetordoff avatar Sep 24 '19 14:09 Johnetordoff

The dry run is very zippy, so the sql-only approach is likely unnecessary, but I'm only able to run it so far. Running the migration gives me:

Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 83, in handle
    executor = MigrationExecutor(connection, self.migration_progress_callback)
  File "/usr/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 20, in __init__
    self.loader = MigrationLoader(self.connection)
  File "/usr/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 52, in __init__
    self.build_graph()
  File "/usr/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 203, in build_graph
    self.load_disk()
  File "/usr/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 114, in load_disk
    migration_module = import_module("%s.%s" % (module_name, migration_name))
  File "/usr/local/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/code/osf/migrations/0182_add_education_employment_models.py", line 10, in <module>
    from osf.management.commands import populate_new_models, put_jobs_and_schools_back
ImportError: cannot import name populate_new_models

brianjgeiger avatar Sep 26 '19 15:09 brianjgeiger