Skip to content

Commit

Permalink
Remove upgrade and restrict providers other than postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Tischenko authored and kozlovsky committed May 16, 2021
1 parent b10ab5c commit 60b3917
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
8 changes: 8 additions & 0 deletions pony/orm/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@

suppress_debug_change = False

supported_providers = ('postgres',)

def sql_debug(value):
# todo: make sql_debug deprecated
if not suppress_debug_change:
Expand Down Expand Up @@ -795,6 +797,12 @@ def _bind(self, *args, **kwargs):
if args: provider, args = args[0], args[1:]
elif 'provider' not in kwargs: throw(TypeError, 'Database provider is not specified')
else: provider = kwargs.pop('provider')
if provider not in supported_providers:
throw(
MappingError,
'This version of Pony is experimental and does not support provider %s. Supported providers are: %s' %
(provider, ', '.join(supported_providers))
)
if isinstance(provider, type) and issubclass(provider, DBAPIProvider):
provider_cls = provider
else:
Expand Down
11 changes: 6 additions & 5 deletions pony/orm/migrations/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@

squash_parser = subparsers.add_parser('squash', help='squash all migrations into the new one')

upgrade_parser = subparsers.add_parser('upgrade', help='upgrade database to current Pony version')
upgrade_parser.add_argument('--sql-only', action='store_true', help='only show sql of upgrade process')
upgrade_parser.add_argument('-v', '--verbose', action='store_true', help='show sql of upgrade process')
#upgrade_parser = subparsers.add_parser('upgrade', help='upgrade database to current Pony version')
#upgrade_parser.add_argument('--sql-only', action='store_true', help='only show sql of upgrade process')
#upgrade_parser.add_argument('-v', '--verbose', action='store_true', help='show sql of upgrade process')

downgrade_parser = subparsers.add_parser('downgrade', help='downgrade database to Pony version 0.7.11')
downgrade_parser.add_argument('--sql-only', action='store_true', help='only show sql of downgrade process')
Expand Down Expand Up @@ -66,8 +66,8 @@ def migrate(db, cmd=None):
m_list(db, graph, args)
elif cmd == 'squash':
squash(db, graph, args)
elif cmd == 'upgrade':
upgrade(db, args)
#elif cmd == 'upgrade':
# upgrade(db, args)
elif cmd == 'downgrade':
downgrade(db, args)
# elif cmd == 'apply':
Expand Down Expand Up @@ -364,6 +364,7 @@ def squash(db, graph, args):


def upgrade(db, args):
raise NotImplementedError
from pony.orm import db_session, commit
vdb = db.vdb
schema = vdb.schema
Expand Down

0 comments on commit 60b3917

Please sign in to comment.