andmemasin/yii2-myabstract 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

andmemasin/yii2-myabstract

Composer 安装命令:

composer require andmemasin/yii2-myabstract

包简介

my custom activerecord classes

README 文档

README

build

Soft delete schema

This major version uses Laravel-style soft-delete timestamp semantics by default.

Default lifecycle columns:

  • created_at
  • updated_at
  • deleted_at

Default audit columns:

  • created_by
  • updated_by
  • deleted_by

Active records have deleted_at IS NULL. Deleted records have deleted_at set to the deletion timestamp.

Apps that still use the previous columns must override the column-name properties on their models until their own migrations are complete:

public string $userCreatedCol = 'user_created';
public string $userUpdatedCol = 'user_updated';
public string $userClosedCol = 'user_closed';
public string $timeCreatedCol = 'time_created';
public string $timeUpdatedCol = 'time_updated';
public string $timeClosedCol = 'time_closed';

Overrides only change column names. They do not preserve the old end-of-time active-row convention; active rows must still have the configured deleted timestamp column set to NULL.

Migrating an app module to 9.x

Migrate one app module or table group at a time.

  1. Update the module package constraint to allow andmemasin/yii2-myabstract:^9.
  2. Add a DB migration that renames the columns:
$this->renameColumn('{{table_name}}', 'time_created', 'created_at');
$this->renameColumn('{{table_name}}', 'time_updated', 'updated_at');
$this->renameColumn('{{table_name}}', 'time_closed', 'deleted_at');
$this->renameColumn('{{table_name}}', 'user_created', 'created_by');
$this->renameColumn('{{table_name}}', 'user_updated', 'updated_by');
$this->renameColumn('{{table_name}}', 'user_closed', 'deleted_by');
  1. Convert active rows to the new Laravel-style soft-delete state:
$this->alterColumn('{{table_name}}', 'deleted_at', $this->dateTime(6)->null());
$this->alterColumn('{{table_name}}', 'deleted_by', $this->integer()->null());
$this->update('{{table_name}}', ['deleted_at' => null, 'deleted_by' => null], ['deleted_by' => [0, null]]);
  1. Replace indexes that include user_closed with equivalent indexes using deleted_at.
  2. Remove old column-name overrides from migrated models.
  3. Keep explicit old-name overrides only on models whose tables are not migrated yet.
  4. Search the module for direct references to old names and update queries/search models/tests:
rg -n "time_created|time_updated|time_closed|user_created|user_updated|user_closed" modules/andmemasin/<module>
  1. Run the module tests and PHPStan before release:
vendor/bin/codecept run modules/andmemasin/<module>/tests
php vendor/bin/phpstan analyze -c modules/andmemasin/<module>/phpstan-dev.neon

Do not dual-write old and new columns. If a module cannot migrate its tables yet, keep it on the old major version or add explicit old-name overrides until that module gets its own migration.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: proprietary
  • 更新时间: 2018-05-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固