Skip to content

CIDatabaseTestCase double-deletes tables #2206

Description

@MGatner

I don't have time to look at this deeper right now but CIDatabaseTestCase has steps to empty the database of tables on refresh:

			// Delete all of the tables to ensure we're at a clean start.
			$tables = $this->db->listTables();

			if (is_array($tables))
			{
				$forge = Database::forge('tests');

				foreach ($tables as $table)
				{

					if ($table === $this->db->DBPrefix . 'migrations')
					{
						continue;
					}

					$forge->dropTable($table, true);
				}
			}

But then it also refreshes migrations right after:

			$this->migrations->regress(0, 'tests');
			$this->migrations->latest('tests');

Since the migrations table is exempt from removal this will cause it to try rolling back migrations on tables that don't exist anymore, so if the migration's down() method doesn't check if_table_exists it will fail.

Probably just moving $this->migrations->regress(0, 'tests'); above the table removal will work?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix them

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions