mirror of
https://github.com/kennethreitz/django-heroku.git
synced 2026-06-05 15:00:17 +00:00
Drop only the tables in the public schema
Instead of dropping and recreating the entire public schema of a database, let's just drop the tables in the schema. Closes gh-17
This commit is contained in:
+11
-7
@@ -17,7 +17,9 @@ class HerokuDiscoverRunner(DiscoverRunner):
|
||||
if not os.environ.get('CI'):
|
||||
raise ValueError(
|
||||
"The CI env variable must be set to enable this functionality. WARNING: "
|
||||
"This test runner will wipe all tables in the database it targets!")
|
||||
"This test runner will wipe all tables in the 'public' schema "
|
||||
"of the database it targets!"
|
||||
)
|
||||
self.keepdb = True
|
||||
return super(HerokuDiscoverRunner, self).setup_databases(**kwargs)
|
||||
|
||||
@@ -25,14 +27,16 @@ class HerokuDiscoverRunner(DiscoverRunner):
|
||||
with connection.cursor() as cursor:
|
||||
cursor.execute(
|
||||
"""
|
||||
DROP SCHEMA public CASCADE;
|
||||
CREATE SCHEMA public;
|
||||
GRANT ALL ON SCHEMA public TO postgres;
|
||||
GRANT ALL ON SCHEMA public TO public;
|
||||
COMMENT ON SCHEMA public IS 'standard public schema';
|
||||
DROP TABLE (
|
||||
SELECT
|
||||
table_name
|
||||
FROM
|
||||
information_schema.tables
|
||||
WHERE
|
||||
table_schema = 'public'
|
||||
) CASCADE;
|
||||
"""
|
||||
)
|
||||
pass
|
||||
|
||||
def teardown_databases(self, old_config, **kwargs):
|
||||
self.keepdb = True
|
||||
|
||||
Reference in New Issue
Block a user