Database disappeared or was deleted
What happens when a DROP DATABASE command is run by mistake.
Your application suddenly reports that it cannot open the database, although nothing changed on the hosting. In many of these cases the database was deleted by a command sent from your side.
How a database gets deleted by mistake
The main user of your database has full permissions to it, including the right to drop the database. We cannot take this permission away. The database is removed from the server when, for example:
- a SQL script containing
DROP DATABASEis run from Visual Studio or SQL Server Management Studio, - Delete is chosen on the database in SSMS Object Explorer,
- a migration or "recreate database" tool is pointed at the hosted database instead of a local one (for example
EnsureDeleted()in Entity Framework).
What to do
Stop the tool that caused it
Make sure the script or application will not run the same command again.
Restore the database
Open Backups for the database in the Control Panel and restore one of your backups, or open a support ticket and ask us to restore the database from our latest backup.
Check your data
A restore brings back the state at the time of the backup. Changes made after that are lost.
How to prevent it
- Read generated SQL scripts before running them against the hosted database and remove
DROP DATABASE/CREATE DATABASEstatements — on the hosting the database already exists. - Keep separate connection strings for development and production so that test tools never touch live data.
- Create your own backup before a larger change: Back up an MSSQL database.