salopensource / sal

Modular reporting for Endpoints
Apache License 2.0
213 stars 64 forks source link

migrate.py failing on 2.2.2 #23

Closed mholttech closed 9 years ago

mholttech commented 9 years ago

I'm trying to upgrade to 2.2.2 from 2.1.1 and am having issues running python manage.py migrate

Here is the error log:

Operations to perform:
  Synchronize unmigrated apps: sal, staticfiles, admindocs, messages, api, bootstrap3
  Apply all migrations: watson, sessions, admin, sites, auth, server, contenttypes, inventory, licenses
Synchronizing apps without migrations:
  Creating tables...
    Running deferred SQL...
  Installing custom SQL...
Running migrations:
  Rendering model states... DONE
  Applying server.0015_auto_20150819_1501...Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 351, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 343, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 394, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 445, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py", line 222, in handle
    executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 110, in migrate
    self.apply_migration(states[migration], migration, fake=fake, fake_initial=fake_initial)
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 148, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/migration.py", line 115, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/operations/fields.py", line 201, in database_forwards
    schema_editor.alter_field(from_model, from_field, to_field)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/schema.py", line 484, in alter_field
    old_db_params, new_db_params, strict)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/schema.py", line 636, in _alter_field
    params,
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/schema.py", line 111, in execute
    cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 79, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 97, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: must be owner of relation server_salsetting
grahamgilbert commented 9 years ago

What database backend are you running? Are you running this on a bare OS or Docker?

mholttech commented 9 years ago

It's running on docker and using your postgres container

On Monday, October 19, 2015, Graham Gilbert notifications@github.com wrote:

What database backend are you running? Are you running this on a bare OS or Docker?

— Reply to this email directly or view it on GitHub https://github.com/salopensource/sal/issues/23#issuecomment-149340466.


[image: Real Life Church] http://www.reallifechurch.org

Michael Holt / IT Administrator (661) 705-4711/ mholt@reallifechurch.org

Real Life Church Office: (661) 775-7401 23841 Newhall Ranch Rd Valencia, CA 91355 http://www.reallifechurch.org

This e-mail message may contain confidential or legally privileged information and is intended only for the use of the intended recipient(s). Any unauthorized disclosure, dissemination, distribution, copying or the taking of any action in reliance on the information herein is prohibited. E-mails are not secure and cannot be guaranteed to be error free as they can be intercepted, amended, or contain viruses. Anyone who communicates with us by e-mail is deemed to have accepted these risks. Company Name is not responsible for errors or omissions in this message and denies any responsibility for any damage arising from the use of e-mail. Any opinion and other statement contained in this message and any attachment are solely those of the author and do not necessarily represent those of the company.

grahamgilbert commented 9 years ago

Did you update the postgres container? There was an issue with that recently. Either way, you'll probably find it easier to roll back to your backup for now whilst I investigate.

Graham Gilbert Sent from my iPhone

On 19 Oct 2015, at 21:40, Michael Holt notifications@github.com wrote:

It's running on docker and using your postgres container

On Monday, October 19, 2015, Graham Gilbert notifications@github.com wrote:

What database backend are you running? Are you running this on a bare OS or Docker?

— Reply to this email directly or view it on GitHub https://github.com/salopensource/sal/issues/23#issuecomment-149340466.


[image: Real Life Church] http://www.reallifechurch.org

Michael Holt / IT Administrator (661) 705-4711/ mholt@reallifechurch.org

Real Life Church Office: (661) 775-7401 23841 Newhall Ranch Rd Valencia, CA 91355 http://www.reallifechurch.org

This e-mail message may contain confidential or legally privileged information and is intended only for the use of the intended recipient(s). Any unauthorized disclosure, dissemination, distribution, copying or the taking of any action in reliance on the information herein is prohibited. E-mails are not secure and cannot be guaranteed to be error free as they can be intercepted, amended, or contain viruses. Anyone who communicates with us by e-mail is deemed to have accepted these risks. Company Name is not responsible for errors or omissions in this message and denies any responsibility for any damage arising from the use of e-mail. Any opinion and other statement contained in this message and any attachment are solely those of the author and do not necessarily represent those of the company. — Reply to this email directly or view it on GitHub.

mholttech commented 9 years ago

Just an FYI I just updated the postgres container and still ran into the error.

grahamgilbert commented 9 years ago

After rolling back to your backup? Normally once a migration goes wonky, there isn't much going back without digging into the database

Graham Gilbert

On Mon, Oct 19, 2015 at 10:20 PM, Michael Holt notifications@github.com wrote:

Just an FYI I just updated the postgres container and still ran into the error.

Reply to this email directly or view it on GitHub: https://github.com/salopensource/sal/issues/23#issuecomment-149350775

mholttech commented 9 years ago

I dug a little and discovered that all of my tables are owned by user "postgres" and not user "sal" which is why I was having issues with the migration. This is what I ran on the postgres container to resolve the problem:

for tbl in `psql -qAt -U postgres -c "select tablename from pg_tables where schemaname = 'public';" sal` ; do  psql -U postgres -c "alter table \"$tbl\" owner to sal" sal ; done
for tbl in `psql -qAt -U postgres -c "select sequence_name from information_schema.sequences where sequence_schema = 'public';" sal` ; do  psql -U postgres -c "alter table \"$tbl\" owner to sal" sal ; done
for tbl in `psql -qAt -U postgres -c "select table_name from information_schema.views where table_schema = 'public';" sal` ; do  psql -U postgres -c "alter table \"$tbl\" owner to sal" sal ; done
grahamgilbert commented 9 years ago

Weird, but good to have in the archives. Glad it got sorted.