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() |