##// END OF EJS Templates
remove not null from user_id column for users log archiving
marcink -
r3065:09e86233 beta
parent child Browse files
Show More
@@ -32,6 +32,19 b' def upgrade(migrate_engine):'
32 # create username column
32 # create username column
33 username.create(table=tbl)
33 username.create(table=tbl)
34
34
35 #alter user_id to not null
36 from rhodecode.lib.dbmigrate.schema.db_1_5_0 import UserLog
37 tbl_name = UserLog.__tablename__
38 tbl = Table(tbl_name,
39 MetaData(bind=migrate_engine), autoload=True,
40 autoload_with=migrate_engine)
41 col = tbl.columns.user_id
42
43 # remove nullability from revision field
44 col.alter(nullable=True)
45
46
47
35 ## after adding that column fix all usernames
48 ## after adding that column fix all usernames
36 users_log = UserLog.query()\
49 users_log = UserLog.query()\
37 .options(joinedload(UserLog.user))\
50 .options(joinedload(UserLog.user))\
@@ -331,6 +331,7 b' class User(Base, BaseModel):'
331 api_key = Column("api_key", String(255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
331 api_key = Column("api_key", String(255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
332 inherit_default_permissions = Column("inherit_default_permissions", Boolean(), nullable=False, unique=None, default=True)
332 inherit_default_permissions = Column("inherit_default_permissions", Boolean(), nullable=False, unique=None, default=True)
333
333
334 user_log = relationship('UserLog')
334 user_perms = relationship('UserToPerm', primaryjoin="User.user_id==UserToPerm.user_id", cascade='all')
335 user_perms = relationship('UserToPerm', primaryjoin="User.user_id==UserToPerm.user_id", cascade='all')
335
336
336 repositories = relationship('Repository')
337 repositories = relationship('Repository')
@@ -522,7 +523,7 b' class UserLog(Base, BaseModel):'
522 'mysql_charset': 'utf8'},
523 'mysql_charset': 'utf8'},
523 )
524 )
524 user_log_id = Column("user_log_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
525 user_log_id = Column("user_log_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
525 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None, default=None)
526 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=True, unique=None, default=None)
526 username = Column("username", String(255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
527 username = Column("username", String(255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
527 repository_id = Column("repository_id", Integer(), ForeignKey('repositories.repo_id'), nullable=True)
528 repository_id = Column("repository_id", Integer(), ForeignKey('repositories.repo_id'), nullable=True)
528 repository_name = Column("repository_name", String(255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
529 repository_name = Column("repository_name", String(255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
General Comments 0
You need to be logged in to leave comments. Login now