blob: bae9638508e3287cd2ea218583dd1d329c9d2e4f [file] [log] [blame]
Matteo Scandolo3896c472017-08-01 13:31:42 -07001
2# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
Zack Williamsa2763112017-01-03 11:38:38 -070017-- Clear the XOS database (used for testing)
18
19CREATE OR REPLACE FUNCTION truncate_tables(username IN VARCHAR) RETURNS void AS $$
20DECLARE
21 statements CURSOR FOR
22 SELECT tablename FROM pg_tables
23 WHERE tableowner = username AND schemaname = 'public';
24BEGIN
25 FOR stmt IN statements LOOP
26 EXECUTE 'TRUNCATE TABLE ' || quote_ident(stmt.tablename) || ' CASCADE;';
27 END LOOP;
28END;
29$$ LANGUAGE plpgsql;
30
31SELECT truncate_tables('postgres');
32
33SELECT setval('core_tenant_id_seq', 1);
34
35SELECT setval('core_deployment_id_seq', 1);
36
37SELECT setval('core_flavor_id_seq', 1);
38
39SELECT setval('core_service_id_seq', 1);
40