Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CIDatabaseTestCase double-deletes tables #2206

Closed
MGatner opened this issue Sep 9, 2019 · 1 comment
Closed

CIDatabaseTestCase double-deletes tables #2206

MGatner opened this issue Sep 9, 2019 · 1 comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@MGatner
Copy link
Member

MGatner commented Sep 9, 2019

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?

@MGatner MGatner added this to the 4.0.0-rc.2 milestone Sep 14, 2019
@MGatner MGatner added the bug Verified issues on the current code behavior or pull requests that will fix them label Sep 14, 2019
@MGatner
Copy link
Member Author

MGatner commented Sep 17, 2019

Resolved by df9e369

@MGatner MGatner closed this as completed Sep 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

No branches or pull requests

1 participant