File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -129,8 +129,19 @@ UPDATE pg_database
129129SET datistemplate = false
130130WHERE datname = ' template_database_name' ;
131131
132+ ` ` ` sql
133+ -- Deactivate connections
134+ SELECT pg_terminate_backend(pid)
135+ FROM pg_stat_activity
136+ WHERE datname = 'source_database_name' or datname = 'new_database_name'
137+ AND pid != pg_backend_pid();
138+ ` ` `
139+
132140-- Drop the template database
133141DROP DATABASE " template_database_name" ;
142+
143+ -- Drop the new database
144+ DROP DATABASE " new_database_name" ;
134145```
135146
136147## Troubleshooting
@@ -159,4 +170,4 @@ DROP DATABASE "template_database_name";
159170
160171## License
161172
162- This project is licensed under the GNU General Public License v3.0 - see the [ LICENSE] ( https://opensource.org/license/mit ) file for details.
173+ This project is licensed under the GNU General Public License v3.0 - see the [ LICENSE] ( https://opensource.org/license/mit ) file for details.
You can’t perform that action at this time.
0 commit comments