Merge "Add backup table for bp add-mysql-support-for-freezer"

This commit is contained in:
Zuul 2018-10-25 10:50:38 +00:00 committed by Gerrit Code Review
commit 69447e1825
2 changed files with 39 additions and 3 deletions

View File

@ -136,7 +136,27 @@ def define_tables(meta):
mysql_charset='utf8'
)
return [clients, sessions, jobs, actions, action_reports]
# The field metadata is json, including :
# nova_inst_id, engine_name, storage, remove_older_than, restore_from_date,
# command, incremental, restore_abs_path, etc
backups = Table(
'backups', meta,
Column('created_at', DateTime(timezone=False)),
Column('updated_at', DateTime(timezone=False)),
Column('deleted_at', DateTime),
Column('deleted', Boolean),
Column('id', String(36), primary_key=True, nullable=False),
Column('client_id', String(255), nullable=False),
Column('job_id', String(36), nullable=False),
Column('project_id', String(36), nullable=False),
Column('user_id', String(64), nullable=False),
Column('user_name', String(64)),
Column('backup_metadata', Text),
mysql_engine='InnoDB',
mysql_charset='utf8'
)
return [clients, sessions, jobs, actions, action_reports, backups]
def upgrade(migrate_engine):

View File

@ -148,16 +148,32 @@ class ActionReport(BASE, FreezerBase):
log = Column(BLOB)
class Backup(BASE, FreezerBase):
"""Represents freezer Backup."""
# The field backup_metadata is json, including :
# nova_inst_id, engine_name, storage, remove_older_than, restore_from_date,
# command, incremental, restore_abs_path, etc
__tablename__ = 'backups'
id = Column(String(36), primary_key=True)
client_id = Column(String(255), nullable=False)
job_id = Column(String(36), nullable=False)
project_id = Column(String(36), nullable=False)
user_id = Column(String(64), nullable=False)
user_name = Column(String(64), nullable=False)
backup_metadata = Column(Text)
def register_models(engine):
_models = (Client, Action, Job, Session,
ActionReport)
ActionReport, Backup)
for _model in _models:
_model.metadata.create_all(engine)
def unregister_models(engine):
_models = (Client, Action, Job, Session,
ActionReport)
ActionReport, Backup)
for _model in _models:
_model.metadata.drop_all(engine)