承接 alphasoft-fr/sql-migration 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

alphasoft-fr/sql-migration

最新稳定版本:2.0.1

Composer 安装命令:

composer require alphasoft-fr/sql-migration

包简介

PHP SQL Migration

README 文档

README

This is a utility library and commands for managing database migrations in SQL.

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

Installation

Use Composer

Composer Require

composer require alphasoft-fr/sql-migration

Requirements

  • PHP version 8.1

Usage

Configuration

  1. Create a configuration file named migration-config.php at the root of your project. You can use the following example as a starting point:
<?php

return [
    'connection' => new PDO('mysql:host=localhost;dbname=mydb', 'username', 'password'),
    'migrations_directory' => __DIR__ . '/migrations',
    // Other configuration options...
];
  1. Customize the configuration options according to your needs. You can provide the PDO connection instance and specify the directory where migration files will be stored.

Generating a Migration File

You can generate a new migration file using the following command:

php vendor/bin/sqlmigration sql:migration:generate

This will create a new migration file in the specified migrations directory with placeholder content for both the up and down migrations.

Modify the generated migration file with SQL queries corresponding to the intended migration:

-- UP MIGRATION --
CREATE TABLE users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    username VARCHAR(50) NOT NULL,
    email VARCHAR(100) NOT NULL,
    created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);

-- DOWN MIGRATION --
DROP TABLE users;

Running Migrations

You can apply pending migrations using the following command:

php vendor/bin/sqlmigration sql:migration:migrate

This command will execute all pending migrations in ascending order of their version numbers. Successfully applied migrations will be displayed in the console output.

Rolling Back Migrations

You can revert the last applied migration using the following command:

php vendor/bin/sqlmigration sql:migration:down <version>

Replace <version> with the version number of the migration you want to revert. This command will execute the down migration for the specified version, effectively rolling back the changes made by that migration.

Contributing

If you encounter any issues or have suggestions for improvements, please feel free to open an issue on the GitHub repository.

License

This project is licensed under the MIT License. See the LICENSE file for details.

统计信息

  • 总下载量: 81
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-06-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固