diff --git a/CLI/src/commands/database/ResetCommand.kt b/CLI/src/commands/database/ResetCommand.kt index d707c1a7..e7fe1688 100644 --- a/CLI/src/commands/database/ResetCommand.kt +++ b/CLI/src/commands/database/ResetCommand.kt @@ -22,9 +22,11 @@ class ResetCommand : CliktCommand() { val schema = schemaFile.readText() + execute("SET FOREIGN_KEY_CHECKS=0;") { } + val tables = execute("SHOW TABLES;") { it.getString(1) } for (table in tables) { - execute("DROP TABLE IF EXISTS $table;") { } + execute("DROP TABLE IF EXISTS `${table.replace("`", "``")}`;") { } } execute(schema) { } @@ -34,6 +36,8 @@ class ResetCommand : CliktCommand() { execute(seed.readText()) { } + execute("SET FOREIGN_KEY_CHECKS=1;") { } + echo(TextColors.brightGreen(TextStyles.bold("Database reset!"))) } }