1 # copyright 2003-2015 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
1 # copyright 2003-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
3 # |
3 # |
4 # This file is part of CubicWeb. |
4 # This file is part of CubicWeb. |
5 # |
5 # |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
153 skip_relations=skip_relations).replace(';', ';;')) |
153 skip_relations=skip_relations).replace(';', ';;')) |
154 if dbhelper.users_support and user: |
154 if dbhelper.users_support and user: |
155 w('') |
155 w('') |
156 w(sqlgrants(schema, driver, user, text_index, set_owner, |
156 w(sqlgrants(schema, driver, user, text_index, set_owner, |
157 skip_relations, skip_entities).replace(';', ';;')) |
157 skip_relations, skip_entities).replace(';', ';;')) |
158 return '\n'.join(output) |
|
159 |
|
160 |
|
161 def sqldropschema(schema, driver, text_index=True, |
|
162 skip_relations=PURE_VIRTUAL_RTYPES, skip_entities=()): |
|
163 """return the sql to drop the schema, according to the given parameters""" |
|
164 from cubicweb.server.schema2sql import dropschema2sql |
|
165 from cubicweb.server.sources import native |
|
166 output = [] |
|
167 w = output.append |
|
168 if text_index: |
|
169 dbhelper = db.get_db_helper(driver) |
|
170 w(dbhelper.sql_drop_fti()) |
|
171 w('') |
|
172 w(dropschema2sql(dbhelper, schema, prefix=SQL_PREFIX, |
|
173 skip_entities=skip_entities, |
|
174 skip_relations=skip_relations)) |
|
175 w('') |
|
176 w(native.sql_drop_schema(driver)) |
|
177 return '\n'.join(output) |
158 return '\n'.join(output) |
178 |
159 |
179 |
160 |
180 _SQL_DROP_ALL_USER_TABLES_FILTER_FUNCTION = re.compile('^(?!(sql|pg)_)').match |
161 _SQL_DROP_ALL_USER_TABLES_FILTER_FUNCTION = re.compile('^(?!(sql|pg)_)').match |
181 def sql_drop_all_user_tables(driver_or_helper, sqlcursor): |
162 def sql_drop_all_user_tables(driver_or_helper, sqlcursor): |