src/SnooPHP/Model/Migration.php
protected function drop()
	{
		// Program status
		$status = true;

		$migration	= $this->lastMigration();
		$tables		= $migration ? unserialize($migration["tables"]) : [];
		if (empty($tables))
		{
			printf("\n\e[1;32m✓\e[0m all ok, nothing to drop\n");
			return true;
		}

		// Compute table dependencies
		// break if circular dependencies are found
		if (($tables = static::computeDependencies($tables)) === false)
		{
			error_log("\n\e[1;31m!\e[0m circular dependency found; terminating program\n");
			return false;
		}

		// Reverse dependency order
		$tables = array_reverse($tables);

		// Get table names
		printf("\n> dropping tables:\n");
		foreach ($tables as $table)
		{
			printf("    ➤ {$table->name()}\n");
			$tableNames[] = $table->name();
		}

		// Begin transaction and run drop query
		// Unfortunately begin transaction has no effect here
		// MySQL adds an implicit commit after DROP TABLE and CREATE TABLE
		Db::beginTransaction($this->dbName);
		try
		{
			Db::query("drop table if exists ".implode(", ", $tableNames), [], $this->dbName, false);
		}
		catch (PDOException $e)
		{
			error_log("\e[1;31m!\e[0m {$e->getMessage()}\n");
			$status = false;
		}

		if ($status)
		{
			// Drop migration table
			if ($this->dropMigrationTable())
			{
				printf("\e[1;32m✓\e[0m tables dropped\n");
				Db::commit($this->dbName);
			}
			else
			{
				printf("\e[1;31m!\e[0m could not drop migration table; reverting all changes ...\n");
				Db::rollBack($this->dbName);
			}
		}
		else
		{
			printf("\e[1;31m!\e[0m something went wrong ...\n");
			Db::rollBack($this->dbName);
		}

		// Return program status
		return $status;
	}
protected function drop()
	{
		// Program status
		$status = true;

		$migration	= $this->lastMigration();
		$tables		= $migration ? unserialize($migration["tables"]) : [];
		if (empty($tables))
		{
			printf("\n\e[1;32m✓\e[0m all ok, nothing to drop\n");
			return true;
		}

		// Compute table dependencies
		// break if circular dependencies are found
		if (($tables = static::computeDependencies($tables)) === false)
		{
			error_log("\n\e[1;31m!\e[0m circular dependency found; terminating program\n");
			return false;
		}

		// Reverse dependency order
		$tables = array_reverse($tables);

		// Get table names
		printf("\n> dropping tables:\n");
		foreach ($tables as $table)
		{
			printf("    ➤ {$table->name()}\n");
			$tableNames[] = $table->name();
		}

		// Begin transaction and run drop query
		// Unfortunately begin transaction has no effect here
		// MySQL adds an implicit commit after DROP TABLE and CREATE TABLE
		Db::beginTransaction($this->dbName);
		try
		{
			Db::query("drop table if exists ".implode(", ", $tableNames), [], $this->dbName, false);
		}
		catch (PDOException $e)
		{
			error_log("\e[1;31m!\e[0m {$e->getMessage()}\n");
			$status = false;
		}

		if ($status)
		{
			// Drop migration table
			if ($this->dropMigrationTable())
			{
				printf("\e[1;32m✓\e[0m tables dropped\n");
				Db::commit($this->dbName);
			}
			else
			{
				printf("\e[1;31m!\e[0m could not drop migration table; reverting all changes ...\n");
				Db::rollBack($this->dbName);
			}
		}
		else
		{
			printf("\e[1;31m!\e[0m something went wrong ...\n");
			Db::rollBack($this->dbName);
		}

		// Return program status
		return $status;
	}
Drop all tables migration

@return bool program status