Migrate job cannot migrate database after restore on devel
k logs ecamp3-dev-db-migrate-v4vwk
Waiting for database to be ready...
The database is now ready and reachable
{"message":"User Deprecated: AbstractPostgreSQLDriver::getSchemaManager() is deprecated. Use PostgreSQLPlatform::createSchemaManager() instead. (AbstractPostgreSQLDriver.php:72 called by TracingDriverForV3.php:80, https://github.com/doctrine/dbal/pull/5458, package doctrine/dbal)","context":{"exception":{"class":"ErrorException","message":"User Deprecated: AbstractPostgreSQLDriver::getSchemaManager() is deprecated. Use PostgreSQLPlatform::createSchemaManager() instead. (AbstractPostgreSQLDriver.php:72 called by TracingDriverForV3.php:80, https://github.com/doctrine/dbal/pull/5458, package doctrine/dbal)","code":0,"file":"/srv/api/vendor/doctrine/deprecations/lib/Doctrine/Deprecations/Deprecation.php:210"}},"level":200,"level_name":"INFO","channel":"php","datetime":"2023-10-01T13:32:23.008789+00:00","extra":{}}
{"message":"Error thrown while running command \"doctrine:migrations:migrate --no-interaction\". Message: \"An exception occurred while executing a query: SQLSTATE[3F000]: Invalid schema name: 7 ERROR: no schema has been selected to create in\nLINE 1: CREATE TABLE doctrine_migration_versions (version VARCHAR(19...\n ^\"","context":{"exception":{"class":"Doctrine\\DBAL\\Exception\\SchemaDoesNotExist","message":"An exception occurred while executing a query: SQLSTATE[3F000]: Invalid schema name: 7 ERROR: no schema has been selected to create in\nLINE 1: CREATE TABLE doctrine_migration_versions (version VARCHAR(19...\n ^","code":7,"file":"/srv/api/vendor/doctrine/dbal/src/Driver/API/PostgreSQL/ExceptionConverter.php:59","previous":{"class":"Doctrine\\DBAL\\Driver\\PDO\\Exception","message":"SQLSTATE[3F000]: Invalid schema name: 7 ERROR: no schema has been selected to create in\nLINE 1: CREATE TABLE doctrine_migration_versions (version VARCHAR(19...\n ^","code":7,"file":"/srv/api/vendor/doctrine/dbal/src/Driver/PDO/Exception.php:28","previous":{"class":"PDOException","message":"SQLSTATE[3F000]: Invalid schema name: 7 ERROR: no schema has been selected to create in\nLINE 1: CREATE TABLE doctrine_migration_versions (version VARCHAR(19...\n ^","code":3,"file":"/srv/api/vendor/doctrine/dbal/src/Driver/PDO/Connection.php:33"}}},"command":"doctrine:migrations:migrate --no-interaction","message":"An exception occurred while executing a query: SQLSTATE[3F000]: Invalid schema name: 7 ERROR: no schema has been selected to create in\nLINE 1: CREATE TABLE doctrine_migration_versions (version VARCHAR(19...\n ^"},"level":500,"level_name":"CRITICAL","channel":"console","datetime":"2023-10-01T13:32:23.025012+00:00","extra":{}}
Maybe exporting the db without a user is not a good idea, or the dev database is somewhat special.
The following things did not help:
CENSORED=> SET search_path = public;
SET
CENSORED=> show search_path;
search_path
-------------
public
(1 row)
CENSORED=> ALTER ROLE CENSORED RESET search_path;
ALTER ROLE
CENSORED=> show search_path;
search_path
-----------------
"$user", public
(1 row)
GRANT ALL PRIVILEGES ON DATABASE CENSORED TO CENSORED;
I leave it for now. One expectation is that if we delete the database and let it be recreated by the cluster, the problem will disappear. I could not reproduce the problem on my fork with dev deployments, pr deployments, staging deployments or prod deployments. (all in the dev cluster of course) But if the problem still exists in staging or in prod, this is not a feasable solution.
It also does not stop us from using the backups. If you run a normal dev deployment later, the migration works and you can use the restore data.