Change the logic to rename the table in the SQLite database to fix the migration issue.
refs #7031pull/63/head
parent
e30cbe2579
commit
fe096116be
|
@ -47,7 +47,12 @@ def upgrade():
|
|||
if version < 5:
|
||||
db.engine.execute('ALTER TABLE server ADD COLUMN role text(64)')
|
||||
if version < 6:
|
||||
db.engine.execute("ALTER TABLE server RENAME TO server_old")
|
||||
# To Save previous data, create temp table
|
||||
|
||||
db.engine.execute("create table server_old as select * from server")
|
||||
|
||||
db.engine.execute("DROP TABLE server")
|
||||
|
||||
db.engine.execute("""
|
||||
CREATE TABLE server (
|
||||
id INTEGER NOT NULL,
|
||||
|
@ -161,7 +166,10 @@ def upgrade():
|
|||
""")
|
||||
|
||||
if version < 12:
|
||||
db.engine.execute("ALTER TABLE server RENAME TO server_old")
|
||||
db.engine.execute("create table server_old as select * from server")
|
||||
|
||||
db.engine.execute("DROP TABLE server")
|
||||
|
||||
db.engine.execute("""
|
||||
CREATE TABLE server (
|
||||
id INTEGER NOT NULL,
|
||||
|
|
|
@ -49,12 +49,6 @@ def upgrade():
|
|||
|
||||
db.engine.execute("DROP TABLE user_old")
|
||||
|
||||
# db.engine.execute("PRAGMA foreign_keys=ON")
|
||||
|
||||
# db.session.commit()
|
||||
|
||||
# db.engine.execute("PRAGMA foreign_keys=ON")
|
||||
|
||||
|
||||
def downgrade():
|
||||
# pgAdmin only upgrades, downgrade not implemented.
|
||||
|
|
|
@ -24,12 +24,19 @@ depends_on = None
|
|||
|
||||
|
||||
def upgrade():
|
||||
db.engine.execute("create table user_old as select * from user")
|
||||
# Rename user table to user_old and again user_old to user to change
|
||||
# the foreign key refernce of user_old table which is not exists
|
||||
|
||||
db.engine.execute("DROP TABLE user")
|
||||
db.engine.execute("ALTER TABLE user RENAME TO user_old")
|
||||
|
||||
db.engine.execute("ALTER TABLE user_old RENAME TO user")
|
||||
|
||||
# Rename server table to server_old and again server_old to server to change
|
||||
# the foreign key refernce of server_old table which is not exists
|
||||
db.engine.execute("ALTER TABLE server RENAME TO server_old")
|
||||
|
||||
db.engine.execute("ALTER TABLE server_old RENAME TO server")
|
||||
|
||||
|
||||
def downgrade():
|
||||
# pgAdmin only upgrades, downgrade not implemented.
|
||||
|
|
|
@ -17,8 +17,11 @@ depends_on = None
|
|||
|
||||
|
||||
def upgrade():
|
||||
# To Save previous data
|
||||
db.engine.execute("ALTER TABLE server RENAME TO server_old")
|
||||
# To Save previous data, create temp table
|
||||
|
||||
db.engine.execute("create table server_old as select * from server")
|
||||
|
||||
db.engine.execute("DROP TABLE server")
|
||||
|
||||
# With service file some fields won't be mandatory as user can provide
|
||||
# them using service file. Removed NOT NULL constraint from few columns
|
||||
|
|
|
@ -19,8 +19,11 @@ depends_on = None
|
|||
|
||||
|
||||
def upgrade():
|
||||
# To Save previous data
|
||||
db.engine.execute("ALTER TABLE server RENAME TO server_old")
|
||||
# To Save previous data, create temp table
|
||||
|
||||
db.engine.execute("create table server_old as select * from server")
|
||||
|
||||
db.engine.execute("DROP TABLE server")
|
||||
|
||||
# Create table with new constraint definition
|
||||
db.engine.execute("""
|
||||
|
|
|
@ -17,8 +17,13 @@ depends_on = None
|
|||
|
||||
|
||||
def upgrade():
|
||||
# Rename older table to save previous data
|
||||
db.engine.execute("ALTER TABLE sharedserver RENAME TO sharedserver_old")
|
||||
|
||||
# To Save previous data, create temp table
|
||||
|
||||
db.engine.execute("create table sharedserver_old as "
|
||||
"select * from sharedserver")
|
||||
|
||||
db.engine.execute("DROP TABLE sharedserver")
|
||||
|
||||
# Create new table with removed not null constraints for port column.
|
||||
db.engine.execute("""
|
||||
|
|
|
@ -19,8 +19,10 @@ depends_on = None
|
|||
|
||||
|
||||
def upgrade():
|
||||
# To Save previous data
|
||||
db.engine.execute("ALTER TABLE server RENAME TO server_old")
|
||||
# To Save previous data, create temp table
|
||||
db.engine.execute("create table server_old as select * from server")
|
||||
|
||||
db.engine.execute("DROP TABLE server")
|
||||
|
||||
# Create table with drop constraint for port and username definition
|
||||
db.engine.execute("""
|
||||
|
|
Loading…
Reference in New Issue