mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-26 04:05:40 +01:00
data migration script to 0.2.0
This commit is contained in:
parent
b13778ef5c
commit
a80e0190c6
@ -93,8 +93,8 @@ create table access_log (
|
||||
log_id int NOT NULL AUTO_INCREMENT,
|
||||
user_id int NOT NULL,
|
||||
project_id int NOT NULL,
|
||||
repo_name varchar (40),
|
||||
repo_tag varchar (20),
|
||||
repo_name varchar (256),
|
||||
repo_tag varchar (128),
|
||||
GUID varchar(64),
|
||||
operation varchar(20) NOT NULL,
|
||||
op_time timestamp,
|
||||
@ -159,4 +159,4 @@ CREATE TABLE IF NOT EXISTS `alembic_version` (
|
||||
`version_num` varchar(32) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
insert into alembic_version values ('0.1.1');
|
||||
insert into alembic_version values ('0.2.0');
|
||||
|
@ -17,3 +17,11 @@ Changelog for harbor database schema
|
||||
- delete data `AMDRWS` from table `role`
|
||||
- delete data `A` from table `access`
|
||||
|
||||
## 0.2.0
|
||||
|
||||
- create table `replication_policy`
|
||||
- create table `replication_target`
|
||||
- create table `replication_job`
|
||||
- add column `repo_tag` to table `access_log`
|
||||
- alter column `repo_name` on table `access_log`
|
||||
- alter column `email` on table `user`
|
||||
|
@ -85,3 +85,42 @@ class Project(Base):
|
||||
deleted = sa.Column(sa.Integer, nullable=False, server_default=sa.text("'0'"))
|
||||
public = sa.Column(sa.Integer, nullable=False, server_default=sa.text("'0'"))
|
||||
owner = relationship(u'User')
|
||||
|
||||
class ReplicationPolicy(Base):
|
||||
__tablename__ = "replication_policy"
|
||||
|
||||
id = sa.Column(sa.Integer, primary_key=True)
|
||||
name = sa.Column(sa.String(256))
|
||||
project_id = sa.Column(sa.Integer, nullable=False)
|
||||
target_id = sa.Column(sa.Integer, nullable=False)
|
||||
enabled = sa.Column(mysql.TINYINT(1), nullable=False, server_default=sa.text("'1'"))
|
||||
description = sa.Column(sa.Text)
|
||||
cron_str = sa.Column(sa.String(256))
|
||||
start_time = sa.Column(mysql.TIMESTAMP)
|
||||
creation_time = sa.Column(mysql.TIMESTAMP, server_default = sa.text("CURRENT_TIMESTAMP"))
|
||||
update_time = sa.Column(mysql.TIMESTAMP, server_default = sa.text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
|
||||
|
||||
class ReplicationTarget(Base):
|
||||
__tablename__ = "replication_target"
|
||||
|
||||
id = sa.Column(sa.Integer, primary_key=True)
|
||||
name = sa.Column(sa.String(64))
|
||||
url = sa.Column(sa.String(64))
|
||||
username = sa.Column(sa.String(40))
|
||||
password = sa.Column(sa.String(40))
|
||||
target_type = sa.Column(mysql.TINYINT(1), nullable=False, server_default=sa.text("'0'"))
|
||||
creation_time = sa.Column(mysql.TIMESTAMP, server_default = sa.text("CURRENT_TIMESTAMP"))
|
||||
update_time = sa.Column(mysql.TIMESTAMP, server_default = sa.text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
|
||||
|
||||
class ReplicationJob(Base):
|
||||
__tablename__ = "replication_job"
|
||||
|
||||
id = sa.Column(sa.Integer, primary_key=True)
|
||||
status = sa.Column(sa.String(64), nullable=False)
|
||||
policy_id = sa.Column(sa.Integer, nullable=False)
|
||||
repository = sa.Column(sa.String(256), nullable=False)
|
||||
operation = sa.Column(sa.String(64), nullable=False)
|
||||
tags = sa.Column(sa.String(16384))
|
||||
creation_time = sa.Column(mysql.TIMESTAMP, server_default = sa.text("CURRENT_TIMESTAMP"))
|
||||
update_time = sa.Column(mysql.TIMESTAMP, server_default = sa.text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
|
||||
|
||||
|
52
migration/migration_harbor/versions/0_2_0.py
Normal file
52
migration/migration_harbor/versions/0_2_0.py
Normal file
@ -0,0 +1,52 @@
|
||||
# Copyright (c) 2008-2016 VMware, Inc. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""0.1.1 to 0.2.0
|
||||
|
||||
Revision ID: 0.1.1
|
||||
Revises:
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0.2.0'
|
||||
down_revision = '0.1.1'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
from alembic import op
|
||||
from db_meta import *
|
||||
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
def upgrade():
|
||||
"""
|
||||
update schema&data
|
||||
"""
|
||||
bind = op.get_bind()
|
||||
#alter column user.email, alter column access_log.repo_name, and add column access_log.repo_tag
|
||||
op.alter_column('user', 'email', type_=sa.String(128), existing_type=sa.String(30))
|
||||
op.alter_column('access_log', 'repo_name', type_=sa.String(256), existing_type=sa.String(40))
|
||||
op.add_column('access_log', sa.Column('repo_tag', sa.String(128)))
|
||||
|
||||
#create tables: replication_policy, replication_target, replication_job
|
||||
ReplicationPolicy.__table__.create(bind)
|
||||
ReplicationTarget.__table__.create(bind)
|
||||
ReplicationJob.__table__.create(bind)
|
||||
|
||||
def downgrade():
|
||||
"""
|
||||
Downgrade has been disabled.
|
||||
"""
|
||||
pass
|
Loading…
Reference in New Issue
Block a user