Coder Social home page Coder Social logo

babl86 / yii-db-migration Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yiisoft/db-migration

0.0 0.0 0.0 632 KB

The package implementing migration for yiisoft/db.

Home Page: https://www.yiiframework.com/

License: BSD 3-Clause "New" or "Revised" License

PHP 100.00%

yii-db-migration's Introduction

Yii DB Migration


The package implementing migration for yiisoft/db.

Latest Stable Version Total Downloads Build status Scrutinizer Code Quality Code Coverage Mutation testing badge static analysis type-coverage

Installation

The package could be installed via composer:

composer require yiisoft/yii-db-migration --prefer-dist

Note: You must install the repository of the implementation to use.

Example:

composer require yiisoft/db-sqlite --prefer-dist

Requirements

  • PHP 8.0 or higher.
  • Filter PHP extension.

Configuration

Example using yiisoft/app.

Di-Container:

Create config/common/db.php with content:

<?php

declare(strict_types=1);

use Yiisoft\Db\Connection\ConnectionInterface;
use Yiisoft\Db\Sqlite\Connection as SqliteConnection;

return [
    ConnectionInterface::class => [
        'class' => SqliteConnection::class,
        '__construct()' => [
            'dsn' => 'sqlite:' . __DIR__ . '/Data/yiitest.sq3'
        ]
    ]
];

Add to config/params.php:

...
'yiisoft/yii-db-migration' => [
    'createNamespace' => 'App\\Migration',
    'updateNamespace' => ['App\\Migration'],
],
...

Now the MigrationService::class uses the View of the application that is already registered in yiisoft/view.

Execute composer du in console config its rebuild.

Now we have the yiisoft/yii-db-migration package configured and it can be called in the console.

View the list of available commands execute in console: ./yii list

Available commands:
  database/list    Lists all tables in the database.
  migrate/create  Generate migration template.
  help             Displays help for a command
  list             Lists commands
  migrate/down     Downgrades the application by reverting old migrations.
  migrate/history  Displays the migration history.
  migrate/new      Displays the first 10 new migrations.
  migrate/redo     Redoes the last few migrations.
  migrate/up       Upgrades the application by applying new migrations.
  serve            Runs PHP built-in web server

Help simple command execute in console ./yii migrate/create --help.

Description:
  Generate migration template.

Usage:
  migrate/create [options] [--] <name>

Arguments:
  name                         Table name for generate migration.

Options:
  -c, --command[=COMMAND]      Command to execute. [default: "create"]
  -f, --fields[=FIELDS]        To create table fields right away
      --and[=AND]              And junction
      --namespace[=NAMESPACE]  Namespace migration
  -h, --help                   Display this help message
  -q, --quiet                  Do not output any message
  -V, --version                Display this application version
      --ansi                   Force ANSI output
      --no-ansi                Disable ANSI output
  -n, --no-interaction         Do not ask any interactive question
  -v|vv|vvv, --verbose         Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
  This command Generate migration template

Testing

Unit testing

The package is tested with PHPUnit. For tests need PostgreSQL database with configuration:

  • host: 127.0.0.1
  • port: 5432
  • name: testdb
  • user: postgres
  • password: postgres

To run tests:

./vendor/bin/phpunit

Mutation testing

The package tests are checked with Infection mutation framework with Infection Static Analysis Plugin. To run it:

./vendor/bin/roave-infection-static-analysis-plugin

Static analysis

The code is statically analyzed with Psalm. To run static analysis:

./vendor/bin/psalm

License

The Yii Db Migration is free software. It is released under the terms of the BSD License. Please see LICENSE for more information.

Maintained by Yii Software.

Support the project

Open Collective

Follow updates

Official website Twitter Telegram Facebook Slack

yii-db-migration's People

Contributors

samdark avatar vjik avatar terabytesoftw avatar dependabot[bot] avatar devanych avatar darkdef avatar xepozz avatar thenotsoft avatar yiiliveext avatar perlexed avatar roxblnfk avatar fantom409 avatar dplusg avatar arhell avatar stylecibot avatar viktorprogger avatar execut avatar mabentley85 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.