cubicweb/misc/migration/3.21.0_Any.py
changeset 11129 97095348b3ee
parent 11108 c14087d08698
parent 11057 0b59724cb3f2
child 11406 8ed625765a5c
equal deleted inserted replaced
11128:9b4de34ad394 11129:97095348b3ee
   164         continue
   164         continue
   165     cstrname, check = check_constraint(rdef.subject, rdef.object, rdef.rtype.type,
   165     cstrname, check = check_constraint(rdef.subject, rdef.object, rdef.rtype.type,
   166             cstr, helper, prefix='cw_')
   166             cstr, helper, prefix='cw_')
   167     args = {'e': rdef.subject.type, 'c': cstrname, 'v': check}
   167     args = {'e': rdef.subject.type, 'c': cstrname, 'v': check}
   168     if repo.system_source.dbdriver == 'postgres':
   168     if repo.system_source.dbdriver == 'postgres':
   169         sql('ALTER TABLE cw_%(e)s DROP CONSTRAINT IF EXISTS %(c)s' % args)
   169         sql('ALTER TABLE cw_%(e)s DROP CONSTRAINT IF EXISTS %(c)s' % args, ask_confirm=False)
   170     elif repo.system_source.dbdriver.startswith('sqlserver'):
   170     elif repo.system_source.dbdriver.startswith('sqlserver'):
   171         sql("IF OBJECT_ID('%(c)s', 'C') IS NOT NULL "
   171         sql("IF OBJECT_ID('%(c)s', 'C') IS NOT NULL "
   172             "ALTER TABLE cw_%(e)s DROP CONSTRAINT %(c)s" % args)
   172             "ALTER TABLE cw_%(e)s DROP CONSTRAINT %(c)s" % args, ask_confirm=False)
   173     sql('ALTER TABLE cw_%(e)s ADD CONSTRAINT %(c)s CHECK(%(v)s)' % args)
   173     sql('ALTER TABLE cw_%(e)s ADD CONSTRAINT %(c)s CHECK(%(v)s)' % args, ask_confirm=False)
   174 commit()
   174 commit()