Zack Williams | a276311 | 2017-01-03 11:38:38 -0700 | [diff] [blame] | 1 | -- Clear the XOS database (used for testing) |
| 2 | |
| 3 | CREATE OR REPLACE FUNCTION truncate_tables(username IN VARCHAR) RETURNS void AS $$ |
| 4 | DECLARE |
| 5 | statements CURSOR FOR |
| 6 | SELECT tablename FROM pg_tables |
| 7 | WHERE tableowner = username AND schemaname = 'public'; |
| 8 | BEGIN |
| 9 | FOR stmt IN statements LOOP |
| 10 | EXECUTE 'TRUNCATE TABLE ' || quote_ident(stmt.tablename) || ' CASCADE;'; |
| 11 | END LOOP; |
| 12 | END; |
| 13 | $$ LANGUAGE plpgsql; |
| 14 | |
| 15 | SELECT truncate_tables('postgres'); |
| 16 | |
| 17 | SELECT setval('core_tenant_id_seq', 1); |
| 18 | |
| 19 | SELECT setval('core_deployment_id_seq', 1); |
| 20 | |
| 21 | SELECT setval('core_flavor_id_seq', 1); |
| 22 | |
| 23 | SELECT setval('core_service_id_seq', 1); |
| 24 | |