mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-13 09:32:01 -06:00
Make the setup process more robust against aborted executions. Fixes #3830
This commit is contained in:
parent
f62d35bf3c
commit
943fc25f60
@ -29,4 +29,5 @@ Bug fixes
|
|||||||
| `Bug #3797 <https://redmine.postgresql.org/issues/3797>`_ - Prevent attempts to bulk-drop schema objects.
|
| `Bug #3797 <https://redmine.postgresql.org/issues/3797>`_ - Prevent attempts to bulk-drop schema objects.
|
||||||
| `Bug #3798 <https://redmine.postgresql.org/issues/3798>`_ - Ensure the browser toolbar buttons work in languages other than English.
|
| `Bug #3798 <https://redmine.postgresql.org/issues/3798>`_ - Ensure the browser toolbar buttons work in languages other than English.
|
||||||
| `Bug #3805 <https://redmine.postgresql.org/issues/3805>`_ - Allow horizontal sizing of the edit grid text pop-out.
|
| `Bug #3805 <https://redmine.postgresql.org/issues/3805>`_ - Allow horizontal sizing of the edit grid text pop-out.
|
||||||
| `Bug #3821 <https://redmine.postgresql.org/issues/3821>`_ - Ensure identifiers are properly displayed in the plan viewer.
|
| `Bug #3821 <https://redmine.postgresql.org/issues/3821>`_ - Ensure identifiers are properly displayed in the plan viewer.
|
||||||
|
| `Bug #3830 <https://redmine.postgresql.org/issues/3830>`_ - Make the setup process more robust against aborted executions.
|
@ -40,6 +40,8 @@ def upgrade():
|
|||||||
if get_version() != -1:
|
if get_version() != -1:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
email, password = user_info()
|
||||||
|
|
||||||
op.create_table('version',
|
op.create_table('version',
|
||||||
sa.Column('name', sa.String(length=32), nullable=False),
|
sa.Column('name', sa.String(length=32), nullable=False),
|
||||||
sa.Column('value', sa.Integer(), nullable=False),
|
sa.Column('value', sa.Integer(), nullable=False),
|
||||||
@ -109,7 +111,6 @@ INSERT INTO "servergroup"
|
|||||||
VALUES(1, 1, 'Servers')
|
VALUES(1, 1, 'Servers')
|
||||||
""")
|
""")
|
||||||
|
|
||||||
email, password = user_info()
|
|
||||||
current_salt = getattr(
|
current_salt = getattr(
|
||||||
config, 'SECURITY_PASSWORD_SALT', base64.urlsafe_b64encode(
|
config, 'SECURITY_PASSWORD_SALT', base64.urlsafe_b64encode(
|
||||||
os.urandom(32)
|
os.urandom(32)
|
||||||
|
@ -33,6 +33,7 @@ from pgadmin.utils.preferences import Preferences
|
|||||||
from pgadmin.utils.session import create_session_interface, pga_unauthorised
|
from pgadmin.utils.session import create_session_interface, pga_unauthorised
|
||||||
from pgadmin.utils.versioned_template_loader import VersionedTemplateLoader
|
from pgadmin.utils.versioned_template_loader import VersionedTemplateLoader
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
from pgadmin.setup import get_version, set_version
|
||||||
|
|
||||||
# If script is running under python3, it will not have the xrange function
|
# If script is running under python3, it will not have the xrange function
|
||||||
# defined
|
# defined
|
||||||
@ -304,11 +305,13 @@ def create_app(app_name=None):
|
|||||||
with app.app_context():
|
with app.app_context():
|
||||||
# Run migration for the first time i.e. create database
|
# Run migration for the first time i.e. create database
|
||||||
from config import SQLITE_PATH
|
from config import SQLITE_PATH
|
||||||
if not os.path.exists(SQLITE_PATH):
|
|
||||||
|
# If version not available, user must have aborted. Tables are not
|
||||||
|
# created and so its an empty db
|
||||||
|
if not os.path.exists(SQLITE_PATH) or get_version() == -1:
|
||||||
db_upgrade(app)
|
db_upgrade(app)
|
||||||
else:
|
else:
|
||||||
version = Version.query.filter_by(name='ConfigDB').first()
|
schema_version = get_version()
|
||||||
schema_version = version.value
|
|
||||||
|
|
||||||
# Run migration if current schema version is greater than the
|
# Run migration if current schema version is greater than the
|
||||||
# schema version stored in version table
|
# schema version stored in version table
|
||||||
@ -317,8 +320,7 @@ def create_app(app_name=None):
|
|||||||
|
|
||||||
# Update schema version to the latest
|
# Update schema version to the latest
|
||||||
if CURRENT_SCHEMA_VERSION > schema_version:
|
if CURRENT_SCHEMA_VERSION > schema_version:
|
||||||
version = Version.query.filter_by(name='ConfigDB').first()
|
set_version(CURRENT_SCHEMA_VERSION)
|
||||||
version.value = CURRENT_SCHEMA_VERSION
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
Mail(app)
|
Mail(app)
|
||||||
|
@ -8,6 +8,6 @@
|
|||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
from .user_info import user_info
|
from .user_info import user_info
|
||||||
from .db_version import get_version
|
from .db_version import get_version, set_version
|
||||||
from .db_upgrade import db_upgrade
|
from .db_upgrade import db_upgrade
|
||||||
from .data_directory import create_app_data_directory
|
from .data_directory import create_app_data_directory
|
||||||
|
@ -17,3 +17,8 @@ def get_version():
|
|||||||
return -1
|
return -1
|
||||||
|
|
||||||
return version.value
|
return version.value
|
||||||
|
|
||||||
|
|
||||||
|
def set_version(new_version):
|
||||||
|
version = Version.query.filter_by(name='ConfigDB').first()
|
||||||
|
version.value = new_version
|
||||||
|
Loading…
Reference in New Issue
Block a user