garrcomm/easy-migrations

简单的数据库迁移

v1.x-dev 2024-06-10 09:18 UTC

This package is auto-updated.

Last update: 2024-09-10 09:50:16 UTC


README

对于具有数据库的简单应用程序,复杂的ORM如迁移可能过于冗余,但数据库版本控制仍然非常有用。

为此目的,我创建了此包。

配置文件

配置文件采用 INI格式
有一些默认位置,配置文件应该位于这些位置。也可以通过--config-file [path]参数或通过使用--config [key] [value]参数指定特定的配置值来指定配置文件。

如果找到多个配置文件或指定了多个配置文件,它们将按以下顺序加载

  1. 当前工作目录中的migrator.ini.dist
  2. 当前工作目录中的migrator.ini
  3. 当前工作目录加"/config/"中的migrator.ini.dist
  4. 当前工作目录加"/config/"中的migrator.ini
  5. 包含migrator可执行文件的目录中的migrator.ini.dist
  6. 包含migrator可执行文件的目录中的migrator.ini
  7. --config-file [path]指定的所有配置文件
  8. --config [key] [value]指定的所有标志

配置文件可能看起来像这样

[migrator]

; The path (relative from the configuration file) and namespace in which migrations will be added
path = app/migrations
;namespace = Migrations

; Default chmod for folders
;path_attr = 0755
; Default chmod for files
;file_attr = 0644

; Can be mysqli, maybe more implementations will be added in the future
engine = mysqli

; MySQLi connection info
hostname = localhost
username = root
password = rootroot
database = mydatabase
port = 3306
;socket = /var/run/mysqld.sock

; Name of the versioning table
;version_table = _migration_versions

[migrator]之外的所有部分都将被忽略,使用--config [key] [value]添加的值将解释为存在于[migrator]部分中。

上面示例中注释掉的价值是默认值。