pgadmin4/web/migrations/versions/7fedf8531802_.py
Pradip Parkale 6b613fdf36 Fixed an issue where SQLite database definition is wrong because the USER_ID FK
references the table user_old which is not available.

Fixes #7031
2021-12-01 17:24:41 +05:30

55 lines
1.3 KiB
Python

"""empty message
Revision ID: 7fedf8531802
Revises: aff1436e3c8c
Create Date: 2020-02-26 11:24:54.353288
"""
from alembic import op
import sqlalchemy as sa
from pgadmin.model import db
# revision identifiers, used by Alembic.
revision = '7fedf8531802'
down_revision = 'aff1436e3c8c'
branch_labels = None
depends_on = None
def upgrade():
db.engine.execute("create table user_old as select * from user")
db.engine.execute("DROP TABLE user")
db.engine.execute("""
CREATE TABLE user (
id INTEGER NOT NULL,
username VARCHAR(256) NOT NULL,
email VARCHAR(256),
password VARCHAR(256),
active BOOLEAN NOT NULL,
confirmed_at DATETIME,
masterpass_check VARCHAR(256),
auth_source VARCHAR(256) NOT NULL DEFAULT 'internal',
PRIMARY KEY (id),
UNIQUE (username, auth_source),
CHECK (active IN (0, 1))
);
""")
db.engine.execute("""
INSERT INTO user (
id, username, email, password, active, confirmed_at, masterpass_check
) SELECT
id, email, email, password, active, confirmed_at, masterpass_check
FROM user_old""")
db.engine.execute("DROP TABLE user_old")
def downgrade():
# pgAdmin only upgrades, downgrade not implemented.
pass