Re: flask db migrate error

From: Radoslaw Garbacz <radoslaw(dot)garbacz(at)xtremedatainc(dot)com>
To: Khushboo Vashi <khushboo(dot)vashi(at)enterprisedb(dot)com>
Cc: pgadmin-hackers <pgadmin-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: flask db migrate error
Date: 2020-01-27 17:13:28
Message-ID: CAHBw7oSGMe6YLfCk3K-sk-Xoj6nMcN0ZUdO3zxuPZQ9CRCT-jA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers

Thank you for your response, found the proper description - it works like a
charm.

On Wed, Jan 22, 2020 at 10:31 PM Khushboo Vashi <
khushboo(dot)vashi(at)enterprisedb(dot)com> wrote:

> Hi,
>
> On Wed, Jan 22, 2020 at 9:06 PM Radoslaw Garbacz <
> radoslaw(dot)garbacz(at)xtremedatainc(dot)com> wrote:
>
>> Hi,
>>
>> As this is my first post I'd like to thank you for your work on this
>> project.
>> Originally I posted this following question to pgsql-gui-dev and was
>> advised to repost here.
>>
>> I have a question regarding modifying configuration db model for pgadmin4:
>> When trying to create a new migration file I get an error:
>> sqlalchemy.exc.NoSuchTableError: user_old
>>
>> You can get the proper steps for the database migration from the README
> file with the "Create Database Migrations" section. (file location:
> <pgAdmin Source Directory>/README).
>
> Thanks,
> Khushboo
>
> The command used: FLASK_APP=pgAdmin4.py flask db migrate -m "Add data
>> groups"
>> The db is initialized with: python setup.py, I also tried:
>> FLASK_APP=pgAdmin4.py flask db init
>>
>> When commenting out (just for tests) content of
>> "web/migrations/versions/35f29b1701bd_.py" I get a similar error but with
>> "server_old".
>> So my question is what is the correct procedure to modify configuration
>> db or how to solve the mentioned issue?
>>
>> Thanks in advance,
>>
>> DETAILS:
>>
>> * pgadmin4 version: cloned from master with latest commit on Jan 13, 2020
>>
>> * Changes in "model/__init__.py":
>> SCHEMA_VERSION = 25
>> ...
>> class DataGroup(db.Model):
>> """Define a data group for the treeview"""
>> __tablename__ = 'datagroup'
>> id = db.Column(db.Integer, primary_key=True)
>> user_id = db.Column(db.Integer, db.ForeignKey('user.id'),
>> nullable=False)
>>
>> name = db.Column(db.String(128), nullable=False)
>> __table_args__ = (db.UniqueConstraint('user_id', 'name'),)
>>
>>
>> * migrate command exception details:
>> ...
>> File
>> "/home/rga/.virtualenvs/pgadmin4/lib/python3.7/site-packages/alembic/util/compat.py",
>> line 173, in load_module_py
>> spec.loader.exec_module(module)
>> File "<frozen importlib._bootstrap_external>", line 728, in exec_module
>> File "<frozen importlib._bootstrap>", line 219, in
>> _call_with_frames_removed
>> File "migrations/env.py", line 94, in <module>
>> run_migrations_online()
>> File "migrations/env.py", line 87, in run_migrations_online
>> context.run_migrations()
>> File "<string>", line 8, in run_migrations
>> File
>> "/home/rga/.virtualenvs/pgadmin4/lib/python3.7/site-packages/alembic/runtime/environment.py",
>> line 846, in run_migrations
>> self.get_context().run_migrations(**kw)
>> File
>> "/home/rga/.virtualenvs/pgadmin4/lib/python3.7/site-packages/alembic/runtime/migration.py",
>> line 507, in run_migrations
>> for step in self._migrations_fn(heads, self):
>> File
>> "/home/rga/.virtualenvs/pgadmin4/lib/python3.7/site-packages/alembic/command.py",
>> line 190, in retrieve_migrations
>> revision_context.run_autogenerate(rev, context)
>> File
>> "/home/rga/.virtualenvs/pgadmin4/lib/python3.7/site-packages/alembic/autogenerate/api.py",
>> line 442, in run_autogenerate
>> self._run_environment(rev, migration_context, True)
>> File
>> "/home/rga/.virtualenvs/pgadmin4/lib/python3.7/site-packages/alembic/autogenerate/api.py",
>> line 482, in _run_environment
>> autogen_context, migration_script
>> File
>> "/home/rga/.virtualenvs/pgadmin4/lib/python3.7/site-packages/alembic/autogenerate/compare.py",
>> line 25, in _populate_migration_script
>> _produce_net_changes(autogen_context, upgrade_ops)
>> File
>> "/home/rga/.virtualenvs/pgadmin4/lib/python3.7/site-packages/alembic/autogenerate/compare.py",
>> line 51, in _produce_net_changes
>> autogen_context, upgrade_ops, schemas
>> File
>> "/home/rga/.virtualenvs/pgadmin4/lib/python3.7/site-packages/alembic/util/langhelpers.py",
>> line 303, in go
>> fn(*arg, **kw)
>> File
>> "/home/rga/.virtualenvs/pgadmin4/lib/python3.7/site-packages/alembic/autogenerate/compare.py",
>> line 83, in _autogen_for_tables
>> autogen_context,
>> File
>> "/home/rga/.virtualenvs/pgadmin4/lib/python3.7/site-packages/alembic/autogenerate/compare.py",
>> line 195, in _compare_tables
>> inspector.reflecttable(t, None)
>> File
>> "/home/rga/.virtualenvs/pgadmin4/lib/python3.7/site-packages/sqlalchemy/engine/reflection.py",
>> line 669, in reflecttable
>> reflection_options,
>> File
>> "/home/rga/.virtualenvs/pgadmin4/lib/python3.7/site-packages/sqlalchemy/engine/reflection.py",
>> line 848, in _reflect_fk
>> **reflection_options
>> File "<string>", line 2, in __new__
>> File
>> "/home/rga/.virtualenvs/pgadmin4/lib/python3.7/site-packages/sqlalchemy/util/deprecations.py",
>> line 128, in warned
>> return fn(*args, **kwargs)
>> File
>> "/home/rga/.virtualenvs/pgadmin4/lib/python3.7/site-packages/sqlalchemy/sql/schema.py",
>> line 506, in __new__
>> metadata._remove_table(name, schema)
>> File
>> "/home/rga/.virtualenvs/pgadmin4/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py",
>> line 68, in __exit__
>> compat.reraise(exc_type, exc_value, exc_tb)
>> File
>> "/home/rga/.virtualenvs/pgadmin4/lib/python3.7/site-packages/sqlalchemy/util/compat.py",
>> line 153, in reraise
>> raise value
>> File
>> "/home/rga/.virtualenvs/pgadmin4/lib/python3.7/site-packages/sqlalchemy/sql/schema.py",
>> line 501, in __new__
>> table._init(name, metadata, *args, **kw)
>> File
>> "/home/rga/.virtualenvs/pgadmin4/lib/python3.7/site-packages/sqlalchemy/sql/schema.py",
>> line 595, in _init
>> resolve_fks=resolve_fks,
>> File
>> "/home/rga/.virtualenvs/pgadmin4/lib/python3.7/site-packages/sqlalchemy/sql/schema.py",
>> line 619, in _autoload
>> _extend_on=_extend_on,
>> File
>> "/home/rga/.virtualenvs/pgadmin4/lib/python3.7/site-packages/sqlalchemy/engine/base.py",
>> line 1615, in run_callable
>> return callable_(self, *args, **kwargs)
>> File
>> "/home/rga/.virtualenvs/pgadmin4/lib/python3.7/site-packages/sqlalchemy/engine/default.py",
>> line 460, in reflecttable
>> table, include_columns, exclude_columns, resolve_fks, **opts
>> File
>> "/home/rga/.virtualenvs/pgadmin4/lib/python3.7/site-packages/sqlalchemy/engine/reflection.py",
>> line 655, in reflecttable
>> raise exc.NoSuchTableError(table.name)
>> sqlalchemy.exc.NoSuchTableError: user_old
>>
>>
>> --
>> Best Regards,
>>
>> Radoslaw Garbacz
>> XtremeData Incorporated
>>
>

--
Best Regards,

Radoslaw Garbacz
XtremeData Incorporated

In response to

Browse pgadmin-hackers by date

  From Date Subject
Next Message Khushboo Vashi 2020-01-28 06:03:57 [pgAdmin4][Patch]: Schema Diff Fixes
Previous Message Dave Page 2020-01-27 16:15:13 Re: Website downtime