diff --git a/.github/workflows/ci-mssql.yml b/.github/workflows/ci-mssql.yml new file mode 100644 index 0000000..e238d8b --- /dev/null +++ b/.github/workflows/ci-mssql.yml @@ -0,0 +1,96 @@ +on: + - pull_request + - push + +name: ci-mssql + +jobs: + tests: + name: PHP ${{ matrix.php }}-mssql-${{ matrix.mssql }} + + env: + key: cache + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + include: + - php: '7.2' + extensions: pdo, pdo_sqlsrv + mssql: 'server:2017-latest' + - php: '7.2' + extensions: pdo, pdo_sqlsrv + mssql: 'server:2019-latest' + - php: '7.3' + extensions: pdo, pdo_sqlsrv + mssql: 'server:2017-latest' + - php: '7.3' + extensions: pdo, pdo_sqlsrv + mssql: 'server:2019-latest' + - php: '7.4' + extensions: pdo, pdo_sqlsrv + mssql: 'server:2017-latest' + - php: '7.4' + extensions: pdo, pdo_sqlsrv + mssql: 'server:2019-latest' + - php: '8.0' + extensions: pdo, pdo_sqlsrv + mssql: 'server:2017-latest' + - php: '8.0' + extensions: pdo, pdo_sqlsrv + mssql: 'server:2019-latest' + - php: '8.1' + extensions: pdo, pdo_sqlsrv + mssql: 'server:2019-latest' + + services: + mssql: + image: mcr.microsoft.com/mssql/${{ matrix.mssql }} + env: + SA_PASSWORD: SSpaSS__1 + ACCEPT_EULA: Y + MSSQL_PID: Developer + ports: + - 11433:1433 + options: --name=mssql --health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'SSpaSS__1' -Q 'SELECT 1'" --health-interval=10s --health-timeout=5s --health-retries=3 + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install PHP with extensions + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: ${{ matrix.extensions }} + ini-values: date.timezone='UTC' + tools: composer:v2, pecl + + - name: Determine composer cache directory on Linux + run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV + + - name: Cache dependencies installed with composer + uses: actions/cache@v2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: | + php${{ matrix.php }}-composer- + + - name: Update composer + run: composer self-update + + - name: Install dependencies with composer + if: matrix.php != '8.1' + run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi + + - name: Install dependencies with composer php 8.1 + if: matrix.php == '8.1' + run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi + + - name: Run tests with phpunit without coverage + env: + DB: sqlserver + run: vendor/bin/phpunit tests/Migrations/Driver/SQLServer diff --git a/.github/workflows/ci-mysql.yml b/.github/workflows/ci-mysql.yml new file mode 100644 index 0000000..3c98c43 --- /dev/null +++ b/.github/workflows/ci-mysql.yml @@ -0,0 +1,93 @@ +on: + - pull_request + - push + +name: ci-mysql + +jobs: + tests: + name: PHP ${{ matrix.php-version }}-mysql-${{ matrix.mysql-version }} + env: + extensions: curl, intl, pdo, pdo_mysql + key: cache-v1 + + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + + php-version: + - "7.4" + - "8.0" + - "8.1" + + mysql-version: + - "5.7" + - "8.0" + + services: + mysql: + image: mysql:${{ matrix.mysql-version }} + env: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: spiral + MYSQL_AUTHENTICATION_PLUGIN: mysql_native_password + ports: + - 13306:3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup cache environment + id: cache-env + uses: shivammathur/cache-extensions@v1 + with: + php-version: ${{ matrix.php-version }} + extensions: ${{ env.extensions }} + key: ${{ env.key }} + + - name: Cache extensions + uses: actions/cache@v2 + with: + path: ${{ steps.cache-env.outputs.dir }} + key: ${{ steps.cache-env.outputs.key }} + restore-keys: ${{ steps.cache-env.outputs.key }} + + - name: Install PHP with extensions + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: ${{ env.extensions }} + ini-values: date.timezone='UTC' + coverage: pcov + + - name: Determine composer cache directory + if: matrix.os == 'ubuntu-latest' + run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV + + - name: Cache dependencies installed with composer + uses: actions/cache@v2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }} + restore-keys: | + php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: Install dependencies with composer + if: matrix.php-version != '8.1' + run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi + + - name: Install dependencies with composer php 8.1 + if: matrix.php-version == '8.1' + run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi + + - name: Run mysql tests with phpunit + env: + DB: mysql + MYSQL: ${{ matrix.mysql-version }} + run: vendor/bin/phpunit tests/Migrations/Driver/MySQL diff --git a/.github/workflows/ci-pgsql.yml b/.github/workflows/ci-pgsql.yml new file mode 100644 index 0000000..a45dc18 --- /dev/null +++ b/.github/workflows/ci-pgsql.yml @@ -0,0 +1,96 @@ +on: + - pull_request + - push + +name: ci-pgsql + +jobs: + tests: + name: PHP ${{ matrix.php-version }}-pgsql-${{ matrix.pgsql-version }} + env: + extensions: curl, intl, pdo, pdo_pgsql + key: cache-v1 + + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + php-version: + - "7.2" + - "7.3" + - "7.4" + - "8.0" + - "8.1" + + pgsql-version: + - "10" + - "11" + - "12" + - "13" + + services: + postgres: + image: postgres:${{ matrix.pgsql-version }} + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: spiral + ports: + - 15432:5432 + options: --name=postgres --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=3 + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup cache environment + id: cache-env + uses: shivammathur/cache-extensions@v1 + with: + php-version: ${{ matrix.php-version }} + extensions: ${{ env.extensions }} + key: ${{ env.key }} + + - name: Cache extensions + uses: actions/cache@v2 + with: + path: ${{ steps.cache-env.outputs.dir }} + key: ${{ steps.cache-env.outputs.key }} + restore-keys: ${{ steps.cache-env.outputs.key }} + + - name: Install PHP with extensions + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: ${{ env.extensions }} + ini-values: date.timezone='UTC' + coverage: pcov + + - name: Determine composer cache directory + if: matrix.os == 'ubuntu-latest' + run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV + + - name: Cache dependencies installed with composer + uses: actions/cache@v2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }} + restore-keys: | + php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: Install dependencies with composer + if: matrix.php-version != '8.1' + run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi + + - name: Install dependencies with composer php 8.1 + if: matrix.php-version == '8.1' + run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi + + - name: Run pgsql tests with phpunit + env: + DB: postgres + POSTGRES: ${{ matrix.pgsql-version }} + run: vendor/bin/phpunit tests/Migrations/Driver/Postgres diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1fea182..ac9aaa1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,7 +13,7 @@ jobs: id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Restore Composer Cache - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} @@ -28,7 +28,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: ['7.2', '7.3', '7.4'] + php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1'] steps: - name: Checkout uses: actions/checkout@v2 @@ -38,118 +38,76 @@ jobs: docker-compose up -d cd .. - name: Setup PHP ${{ matrix.php-versions }} - uses: shivammathur/setup-php@v1 + uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} coverage: pcov tools: pecl - extensions: mbstring, pdo, pdo_sqlsrv - - name: Install MS SQL Server deps - run: | - bash ./tests/install-sqlsrv.sh - sudo sed -i.bak '/^extension="pdo_sqlsrv.so"/d' /etc/php/${{ matrix.php-versions }}/cli/php.ini - sudo bash -c 'printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /etc/php/${{ matrix.php-versions }}/mods-available/pdo_sqlsrv.ini' - sudo phpenmod -s cli -v ${{ matrix.php-versions }} pdo_sqlsrv + extensions: mbstring, pdo, pdo_sqlite, pdo_pgsql, pdo_sqlsrv, pdo_mysql - name: Get Composer Cache Directory id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Restore Composer Cache - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer- - - name: Install Dependencies - run: composer install --no-interaction --prefer-dist + + - name: Install dependencies with composer + if: matrix.php-versions != '8.1' + run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi + + - name: Install dependencies with composer php 8.1 + if: matrix.php-versions == '8.1' + run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi + - name: Execute Tests run: | vendor/bin/phpunit --coverage-clover=coverage.xml - name: Upload coverage to Codecov + continue-on-error: true # if is fork uses: codecov/codecov-action@v1 with: token: ${{ secrets.CODECOV_TOKEN }} file: ./coverage.xml - test_postgres: - needs: lint - name: Test PostgreSQL ${{ matrix.configs.postgres-version }} + + sqlite: + name: SQLite PHP ${{ matrix.php-versions }} runs-on: ubuntu-latest strategy: matrix: - configs: [ - {php-version: 7.2, postgres-version: 9.6}, - {php-version: 7.3, postgres-version: 10}, - {php-version: 7.3, postgres-version: 11} - ] - services: - postgres: - image: postgres:${{ matrix.configs.postgres-version }} - ports: - - 5432:5432 - env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: spiral - options: --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=3 + php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1'] steps: - name: Checkout uses: actions/checkout@v2 - - name: Setup PHP ${{ matrix.configs.php-version }} - run: sudo update-alternatives --set php /usr/bin/php${{ matrix.configs.php-version }} - - name: Get Composer Cache Directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - name: Restore Composer Cache - uses: actions/cache@v1 + - name: Setup PHP ${{ matrix.php-versions }} + uses: shivammathur/setup-php@v2 with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: ${{ runner.os }}-composer- - - name: Install Dependencies - run: composer install --no-interaction --prefer-dist - - name: Execute Tests - env: - DB: postgres - POSTGRES: ${{ matrix.configs.postgres-version }} - run: | - vendor/bin/phpunit tests/Migrations/Driver/Postgres - test_mariadb: - needs: lint - name: Test MariaDB ${{ matrix.configs.mariadb-version }} - runs-on: ubuntu-latest - strategy: - matrix: - configs: [ -# {php-version: 7.2, mariadb-version: 10.2}, - {php-version: 7.3, mariadb-version: 10.4} - ] - services: - mariadb: - image: mariadb:${{ matrix.configs.mariadb-version }} - ports: - - 23306:3306 - env: - MYSQL_ROOT_PASSWORD: root - MYSQL_DATABASE: spiral - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Setup PHP ${{ matrix.configs.php-version }} - run: sudo update-alternatives --set php /usr/bin/php${{ matrix.configs.php-version }} + php-version: ${{ matrix.php-versions }} + coverage: pcov + tools: pecl + extensions: mbstring, pdo, pdo_sqlite - name: Get Composer Cache Directory id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Restore Composer Cache - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer- - - name: Install Dependencies - run: composer install --no-interaction --prefer-dist + + - name: Install dependencies with composer + if: matrix.php-versions != '8.1' + run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi + + - name: Install dependencies with composer php 8.1 + if: matrix.php-versions == '8.1' + run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi + - name: Execute Tests env: - DB: mariadb - MARIADB: ${{ matrix.configs.mariadb-version }} + DB: sqlite run: | - vendor/bin/phpunit tests/Migrations/Driver/MySQL + vendor/bin/phpunit tests/Migrations/Driver/SQLite diff --git a/.styleci.yml b/.styleci.yml index a6cd886..1edd305 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -12,7 +12,6 @@ enabled: - combine_nested_dirname - declare_strict_types - dir_constant - - final_static_access - fully_qualified_strict_types - function_to_constant - hash_to_slash_comment diff --git a/composer.json b/composer.json index 4ab9a13..12245d3 100644 --- a/composer.json +++ b/composer.json @@ -5,18 +5,21 @@ "description": "Cycle ORM Migration generation", "require": { "php": ">=7.2", - "cycle/database": "dev-master", - "cycle/schema-builder": "2.0.x-dev", - "cycle/migrations": "2.0.x-dev" + "cycle/database": "^1.0.2", + "cycle/schema-builder": "^1.2", + "cycle/migrations": "^2.0" }, "require-dev": { - "cycle/orm": "2.0.x-dev", + "cycle/orm": "^1.7.1", "phpunit/phpunit": "~8.0", - "cycle/annotated": "2.0.x-dev", + "cycle/annotated": "^2.4", "spiral/debug": "^2.7", "spiral/code-style": "^1.0" }, "autoload": { + "files": [ + "src/polyfill.php" + ], "psr-4": { "Cycle\\Schema\\Generator\\Migrations\\": "src/" } @@ -25,5 +28,10 @@ "psr-4": { "Cycle\\Schema\\Generator\\Migrations\\Tests\\": "tests/Migrations/" } - } + }, + "config": { + "sort-packages": true + }, + "minimum-stability": "dev", + "prefer-stable": true } diff --git a/resources/.phpstorm.meta.php b/resources/.phpstorm.meta.php new file mode 100644 index 0000000..a3e2714 --- /dev/null +++ b/resources/.phpstorm.meta.php @@ -0,0 +1,27 @@ +repository = $migrationRepository; $this->migrationConfig = $migrationConfig; @@ -179,3 +185,4 @@ private function generateName(Atomizer $atomizer): string return implode('_', $name); } } +\class_alias(GenerateMigrations::class, CycleMigrationsGenerateMigrations::class, false); diff --git a/src/MigrationImage.php b/src/MigrationImage.php index 26a11cd..c919dd3 100644 --- a/src/MigrationImage.php +++ b/src/MigrationImage.php @@ -8,6 +8,10 @@ use Cycle\Migrations\Migration; use Spiral\Reactor\ClassDeclaration; use Spiral\Reactor\FileDeclaration; +use Spiral\Migrations\Config\MigrationConfig as SpiralMigrationConfig; +use Cycle\Migrations\MigrationImage as CycleMigrationsMigrationImage; + +\class_exists(SpiralMigrationConfig::class); class MigrationImage { @@ -34,7 +38,7 @@ class MigrationImage * @param MigrationConfig $config * @param string $database */ - public function __construct(MigrationConfig $config, string $database) + public function __construct(SpiralMigrationConfig $config, string $database) { $this->migrationConfig = $config; $this->class = new ClassDeclaration('newMigration', 'Migration'); @@ -122,3 +126,4 @@ public function setName(string $name): void $this->name = $name; } } +\class_alias(MigrationImage::class, CycleMigrationsMigrationImage::class, false); diff --git a/src/polyfill.php b/src/polyfill.php new file mode 100644 index 0000000..bc6da07 --- /dev/null +++ b/src/polyfill.php @@ -0,0 +1,26 @@ + 'default', 'databases' => [], ])); - $this->dbal->addDatabase(new Database( - 'default', - '', - $this->getDriver() - )); - $this->dbal->addDatabase(new Database( - 'secondary', - 'secondary_', - $this->getDriver() - )); + $default = new Database('default', '', $this->getDriver()); + $secondary = new Database('secondary', 'secondary_', $this->getDriver()); + + $this->dbal->addDatabase($default); + $this->dbal->addDatabase($secondary); $this->logger = new TestLogger(); $this->getDriver()->setLogger($this->logger); @@ -138,15 +135,12 @@ public function setUp(): void $this->dbal, new FileRepository( $config, - new Container(), - new Tokenizer(new TokenizerConfig([ - 'directories' => [__DIR__ . '/../files'], - 'exclude' => [], - ])) + new Container() ) ); - $this->migrator->configure(); + (new MigrationsTable($default, $config->getTable()))->actualize(); + (new MigrationsTable($secondary, $config->getTable()))->actualize(); } /** @@ -173,16 +167,13 @@ public function tearDown(): void * * @return \Cycle\ORM\ORMInterface|ORM */ - public function withSchema(SchemaInterface $schema) + public function withSchema(SchemaInterface $schema): ORM { $this->orm = $this->orm->withSchema($schema); return $this->orm; } - /** - * @return Driver - */ - public function getDriver(): Driver + public function getDriver(): DriverInterface { if (isset(static::$driverCache[static::DRIVER])) { return static::$driverCache[static::DRIVER]; @@ -214,18 +205,18 @@ protected function migrate(string $directory): array $locator = $tokenizer->classLocator(); - $p = Generator::getDefaultParser(); + $reader = new AnnotationReader(); $r = new Registry($this->dbal); - $schema = (new Compiler())->compile($r, [ - new Entities($locator, $p), + (new Compiler())->compile($r, [ + new Entities($locator, $reader), new ResetTables(), - new MergeColumns($p), + new MergeColumns($reader), new GenerateRelations(), new ValidateEntities(), new RenderTables(), new RenderRelations(), - new MergeIndexes($p), + new MergeIndexes($reader), new GenerateTypecast(), new GenerateMigrations($this->migrator->getRepository(), new MigrationConfig(static::CONFIG)), ]); @@ -237,20 +228,14 @@ protected function migrate(string $directory): array return $tables; } - /** - * @return Database - */ protected function getDatabase(): Database { return $this->dbal->database('default'); } - /** - * @param Database|null $database - */ - protected function dropDatabase(Database $database = null): void + protected function dropDatabase(?Database $database = null): void { - if (empty($database)) { + if (null === $database) { return; } @@ -294,7 +279,7 @@ protected function disableProfiling(): void protected function assertSameAsInDB(AbstractTable $current): void { $source = $current->getState(); - $target = $current->getDriver()->getSchema($current->getName())->getState(); + $target = $current->getDriver()->getSchemaHandler()->getSchema($current->getName())->getState(); // testing changes @@ -402,7 +387,7 @@ protected function assertSameAsInDB(AbstractTable $current): void // everything else $comparator = new Comparator( $current->getState(), - $current->getDriver()->getSchema($current->getName())->getState() + $current->getDriver()->getSchemaHandler()->getSchema($current->getName())->getState() ); if ($comparator->hasChanges()) { @@ -410,13 +395,7 @@ protected function assertSameAsInDB(AbstractTable $current): void } } - /** - * @param string $table - * @param Comparator $comparator - * - * @return string - */ - protected function makeMessage(string $table, Comparator $comparator) + protected function makeMessage(string $table, Comparator $comparator): string { if ($comparator->isPrimaryChanged()) { return "Table '{$table}' not synced, primary indexes are different."; diff --git a/tests/Migrations/Fixtures/Alter/Other.php b/tests/Migrations/Fixtures/Alter/Other.php index bdd77f4..ecaea41 100644 --- a/tests/Migrations/Fixtures/Alter/Other.php +++ b/tests/Migrations/Fixtures/Alter/Other.php @@ -11,20 +11,23 @@ namespace Cycle\Schema\Generator\Migrations\Tests\Fixtures\Alter; +use Cycle\Annotated\Annotation\Column; +use Cycle\Annotated\Annotation\Entity; + /** - * @entity(database=secondary) + * @Entity(database = "secondary") */ class Other { /** - * @column(type=primary) + * @Column(type = "primary") * * @var int */ protected $id; /** - * @column(type="enum(active,disabled,pending)",castDefault=true) + * @Column(type = "enum(active,disabled,pending)") * * @var string */ diff --git a/tests/Migrations/Fixtures/Alter/Post.php b/tests/Migrations/Fixtures/Alter/Post.php index 1647214..aa25e21 100644 --- a/tests/Migrations/Fixtures/Alter/Post.php +++ b/tests/Migrations/Fixtures/Alter/Post.php @@ -11,20 +11,24 @@ namespace Cycle\Schema\Generator\Migrations\Tests\Fixtures\Alter; +use Cycle\Annotated\Annotation\Column; +use Cycle\Annotated\Annotation\Entity; +use Cycle\Annotated\Annotation\Relation\BelongsTo; + /** - * @entity + * @Entity */ class Post { /** - * @column(type=primary) + * @Column(type = "primary") * * @var int */ protected $id; /** - * @refersTo(target=Other,nullable=true) + * @BelongsTo(target = "Other") * * @var Other */ diff --git a/tests/Migrations/Fixtures/Alter/User.php b/tests/Migrations/Fixtures/Alter/User.php index 4e91b1e..fde2193 100644 --- a/tests/Migrations/Fixtures/Alter/User.php +++ b/tests/Migrations/Fixtures/Alter/User.php @@ -11,13 +11,16 @@ namespace Cycle\Schema\Generator\Migrations\Tests\Fixtures\Alter; +use Cycle\Annotated\Annotation\Column; +use Cycle\Annotated\Annotation\Entity; + /** - * @entity + * @Entity */ class User { /** - * @column(type=primary) + * @Column(type = "primary") * * @var int */ diff --git a/tests/Migrations/Fixtures/Init/Other.php b/tests/Migrations/Fixtures/Init/Other.php index a36bc83..45159be 100644 --- a/tests/Migrations/Fixtures/Init/Other.php +++ b/tests/Migrations/Fixtures/Init/Other.php @@ -11,20 +11,23 @@ namespace Cycle\Schema\Generator\Migrations\Tests\Fixtures\Init; +use Cycle\Annotated\Annotation\Column; +use Cycle\Annotated\Annotation\Entity; + /** - * @entity(database=secondary) + * @Entity(database = "secondary") */ class Other { /** - * @column(type=primary) + * @Column(type = "primary") * * @var int */ protected $id; /** - * @column(type="enum(active,disabled)",castDefault=true) + * @Column(type = "enum(active,disabled)") * * @var string */ diff --git a/tests/Migrations/Fixtures/Init/Post.php b/tests/Migrations/Fixtures/Init/Post.php index c84889b..6d891da 100644 --- a/tests/Migrations/Fixtures/Init/Post.php +++ b/tests/Migrations/Fixtures/Init/Post.php @@ -11,20 +11,24 @@ namespace Cycle\Schema\Generator\Migrations\Tests\Fixtures\Init; +use Cycle\Annotated\Annotation\Column; +use Cycle\Annotated\Annotation\Entity; +use Cycle\Annotated\Annotation\Relation\BelongsTo; + /** - * @entity + * @Entity */ class Post { /** - * @column(type=primary) + * @Column(type = "primary") * * @var int */ protected $id; /** - * @belongsTo(target=User,nullable=false) + * @BelongsTo(target = "User") * * @var User */ diff --git a/tests/Migrations/Fixtures/Init/User.php b/tests/Migrations/Fixtures/Init/User.php index 4a27c63..42cf8f0 100644 --- a/tests/Migrations/Fixtures/Init/User.php +++ b/tests/Migrations/Fixtures/Init/User.php @@ -11,23 +11,30 @@ namespace Cycle\Schema\Generator\Migrations\Tests\Fixtures\Init; +use Cycle\Annotated\Annotation\Column; +use Cycle\Annotated\Annotation\Entity; +use Cycle\Annotated\Annotation\Table; +use Cycle\Annotated\Annotation\Table\Index; + /** - * @entity - * @table( - * indexes={@index(columns={email},unique=true)} + * @Entity + * @Table( + * indexes={ + * @Index(columns = {"email"}, unique = true) + * } * ) */ class User { /** - * @column(type=primary) + * @Column(type = "primary") * * @var int */ protected $id; /** - * @column(type=string) + * @Column(type = "string") * * @var string */ diff --git a/tests/bootstrap.php b/tests/bootstrap.php index dc6d594..12a4e5e 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -51,28 +51,13 @@ return !in_array('sqlsrv', \PDO::getAvailableDrivers()); }, 'conn' => 'sqlsrv:Server=127.0.0.1,11433;Database=tempdb', - 'user' => 'sa', + 'user' => 'SA', 'pass' => 'SSpaSS__1', ], ]; if (!empty(getenv('DB'))) { switch (getenv('DB')) { - case 'postgres': - \Cycle\Schema\Generator\Migrations\Tests\BaseTest::$config = [ - 'debug' => false, - 'postgres' => [ - 'driver' => \Cycle\Database\Driver\Postgres\PostgresDriver::class, - 'check' => function () { - return true; - }, - 'conn' => 'pgsql:host=127.0.0.1;port=5432;dbname=spiral', - 'user' => 'postgres', - 'pass' => 'postgres', - ], - ]; - break; - case 'mariadb': \Cycle\Schema\Generator\Migrations\Tests\BaseTest::$config = [ 'debug' => false, diff --git a/tests/docker-compose.yml b/tests/docker-compose.yml index 7951e77..8b600da 100644 --- a/tests/docker-compose.yml +++ b/tests/docker-compose.yml @@ -2,7 +2,7 @@ version: "3" services: sqlserver: - image: microsoft/mssql-server-linux + image: mcr.microsoft.com/mssql/server:2019-latest ports: - "11433:1433" environment: