Skip to content

Conversation

@amatsuda
Copy link
Contributor

@amatsuda amatsuda commented Jun 7, 2019

SQLServer sometimes (actually very often in my experience) fails to drop database with
Cannot drop database [DATABASE_NAME] because it is currently in use. error in some environments.

https://stackoverflow.com/questions/12702524/unable-to-drop-and-create-database-in-sql-server/12702579#12702579
https://dba.stackexchange.com/questions/2387/sql-server-cannot-drop-database-dbname-because-it-is-currently-in-use-but-n/2391#2391
https://www.mytechmantra.com/LearnSQLServer/Drop-Database-in-SQL-Server-by-Killing-Existing-Connections.html
https://serverfault.com/questions/440034/how-to-force-a-drop-of-mssql-server-database

This patch addresses this FAQ pitfall by changing the target DB to be SINGLE_USER mode before dropping, to make sure no other connections are alive.

to make sure no other connections are alive
@wpolicarpo wpolicarpo merged commit b6cc40b into rails-sqlserver:master Jun 22, 2019
@amatsuda amatsuda deleted the set_single_user_before_drop branch June 23, 2019 02:11
wpolicarpo added a commit that referenced this pull request Jun 24, 2019
SET SINGLE_USER before dropping the database
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants