database: dropped CheckConstraint for auto-increment field for mysql/mariadb compatability.
- https://mariadb.com/kb/en/library/constraint/#auto_increment - causes installation error on later MariaDB/MySQL
This commit is contained in:
parent
6d14e55ab7
commit
844d7374eb
39 changed files with 12 additions and 41 deletions
|
|
@ -680,7 +680,7 @@ class Repository(Base, BaseModel):
|
|||
class Group(Base, BaseModel):
|
||||
__tablename__ = 'groups'
|
||||
__table_args__ = (UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'), {'extend_existing':True},)
|
||||
{'extend_existing':True},)
|
||||
__mapper_args__ = {'order_by':'group_name'}
|
||||
|
||||
group_id = Column("group_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
|
||||
|
|
|
|||
|
|
@ -699,7 +699,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine':'InnoDB',
|
||||
'mysql_charset': 'utf8'},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -513,7 +513,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8'},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -526,7 +526,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8'},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -543,7 +543,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8'},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -626,7 +626,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8'},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -597,7 +597,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8'},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -599,7 +599,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -622,7 +622,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -621,7 +621,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -639,7 +639,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -656,7 +656,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -672,7 +672,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -675,7 +675,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -679,7 +679,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -679,7 +679,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -707,7 +707,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -717,7 +717,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -760,7 +760,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -758,7 +758,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -759,7 +759,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -759,7 +759,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -765,7 +765,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -887,7 +887,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -912,7 +912,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2295,7 +2295,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2361,7 +2361,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2436,7 +2436,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
base_table_args,
|
||||
)
|
||||
__mapper_args__ = {'order_by': 'group_name'}
|
||||
|
|
|
|||
|
|
@ -2459,7 +2459,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
base_table_args,
|
||||
)
|
||||
__mapper_args__ = {'order_by': 'group_name'}
|
||||
|
|
|
|||
|
|
@ -2459,7 +2459,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
base_table_args,
|
||||
)
|
||||
__mapper_args__ = {'order_by': 'group_name'}
|
||||
|
|
|
|||
|
|
@ -2007,7 +2007,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1999,7 +1999,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1998,7 +1998,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2000,7 +2000,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2000,7 +2000,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2043,7 +2043,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2044,7 +2044,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2231,7 +2231,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
{'extend_existing': True, 'mysql_engine': 'InnoDB',
|
||||
'mysql_charset': 'utf8', 'sqlite_autoincrement': True},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2460,7 +2460,6 @@ class RepoGroup(Base, BaseModel):
|
|||
__tablename__ = 'groups'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('group_name', 'group_parent_id'),
|
||||
CheckConstraint('group_id != group_parent_id'),
|
||||
base_table_args,
|
||||
)
|
||||
__mapper_args__ = {'order_by': 'group_name'}
|
||||
|
|
@ -2481,8 +2480,7 @@ class RepoGroup(Base, BaseModel):
|
|||
users_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
|
||||
parent_group = relationship('RepoGroup', remote_side=group_id)
|
||||
user = relationship('User')
|
||||
integrations = relationship('Integration',
|
||||
cascade="all, delete, delete-orphan")
|
||||
integrations = relationship('Integration', cascade="all, delete, delete-orphan")
|
||||
|
||||
def __init__(self, group_name='', parent_group=None):
|
||||
self.group_name = group_name
|
||||
|
|
@ -2492,6 +2490,16 @@ class RepoGroup(Base, BaseModel):
|
|||
return u"<%s('id:%s:%s')>" % (
|
||||
self.__class__.__name__, self.group_id, self.group_name)
|
||||
|
||||
@validates('group_parent_id')
|
||||
def validate_group_parent_id(self, key, val):
|
||||
"""
|
||||
Check cycle references for a parent group to self
|
||||
"""
|
||||
if self.group_id and val:
|
||||
assert val != self.group_id
|
||||
|
||||
return val
|
||||
|
||||
@hybrid_property
|
||||
def description_safe(self):
|
||||
from rhodecode.lib import helpers as h
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue