Hello,
Context
I’m working on a Symfony project, using doctrine as ORM with mariadb as driver.
To test my different job, I’m working with gitlab-runner in local on MacOs.
Problem
I create a job to test the creation of my different databases and the migrations for the both.
I’m using the symfony-cli command line to create my databses from the doctrine’s file configuration (see in the section Source File)
The command line to create database with symfony-cli
$ php bin/console doctrine:database:create --env=test --if-not-exists --connection=[CONNECTION_NAME]
The error prompt when the command line from is ask to run
$ php bin/console doctrine:database:create --env=test --if-not-exists --connection=CleanerFuture
Could not create database `cf_CleanerFuture` for connection named CleanerFuture
An exception occurred while executing 'CREATE DATABASE `cf_CleanerFuture`':
SQLSTATE[42000]: Syntax error or access violation: 1044 Access denied for user 'myapptest'@'%' to database 'cf_CleanerFuture'
Goal
Well my goal it’s to try to create the database base with this commande line to run my job and past to the next one
Source File
.gitlab-ci.yml
This is the job I try to execute
doctrine-migrations:
image: php:7.3
stage: Migrations
services:
- name: mysql:5.7
alias: mysql
variables:
ENV: test
MYSQL_ROOT_PASSWORD: pass_test
MYSQL_DATABASE: cf_Central
MYSQL_USER: myapptest
MYSQL_PASSWORD: myapptest
DATABASE_URL: 'mysql://myapptest:myapptest@mysql:3306/'
before_script:
- apt-get update
- apt-get install -y git libzip-dev
- curl -sSk https://getcomposer.org/installer | php -- --disable-tls && mv composer.phar /usr/local/bin/composer
- docker-php-ext-install mysqli pdo pdo_mysql zip
- curl -sS https://get.symfony.com/cli/installer | bash
- mv /root/.symfony/bin/symfony /usr/local/bin/symfony
- composer remove ext-xdebug
- composer install
script:
- php bin/console doctrine:database:drop --force --if-exists --env=test --connection=default
- php bin/console doctrine:database:drop --force --if-exists --env=test --connection=CleanerFuture
- php bin/console doctrine:database:create --env=test --if-not-exists --connection=CleanerFuture
- php bin/console doctrine:migrations:migrate --env=test
allow_failure: false
config/test/doctrine.yaml
doctrine:
dbal:
default_connection: default
connections:
default:
url: '%env(resolve:DATABASE_URL)%cf_central'
server_version: "mariadb-10.4.11"
driver: 'pdo_mysql'
charset: utf8
CleanerFuture:
url: '%env(resolve:DATABASE_URL)%cf_CleanerFuture'
server_version: "mariadb-10.4.11"
driver: 'pdo_mysql'
charset: utf8
orm:
auto_generate_proxy_classes: true
default_entity_manager: default
entity_managers:
default:
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
connection: default
mappings:
Central:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity/Central'
prefix: 'App\Entity\Central'
CleanerFuture:
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
connection: CleanerFuture
mappings:
Client:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity/Client'
prefix: 'App\Entity\Client'
Thank for your time,
Sincerely,