Download the PHP package andmemasin/yii2-myabstract without Composer
On this page you can find all versions of the php package andmemasin/yii2-myabstract. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download andmemasin/yii2-myabstract
More information about andmemasin/yii2-myabstract
Files in andmemasin/yii2-myabstract
Package yii2-myabstract
Short Description my custom activerecord classes
License proprietary
Informations about the package yii2-myabstract
Yii2-Myabstracts
Soft delete schema
This major version uses Laravel-style soft-delete timestamp semantics by default.
Default lifecycle columns:
created_atupdated_atdeleted_at
Default audit columns:
created_byupdated_bydeleted_by
Active records have deleted_at IS NULL. Deleted records have deleted_at set to the deletion timestamp.
This package keeps timestamp values as DATETIME(6) / Y-m-d H:i:s.u values. Laravel's migration helpers commonly create SQL TIMESTAMP columns for created_at, updated_at, and deleted_at, but that is not a UNIX integer timestamp. Both DATETIME(6) and TIMESTAMP(6) are read by Laravel/Eloquent as date objects.
The practical difference is timezone handling: MySQL DATETIME stores the exact calendar value written, while MySQL TIMESTAMP can be converted according to the DB session timezone. Keeping DATETIME(6) avoids timezone surprises during the Yii-to-Laravel transition. A future schema cleanup may convert these columns to TIMESTAMP(6) if strict Laravel migration-helper compatibility becomes more important than preserving current DB behavior.
Apps that still use the previous columns must override the column-name properties on their models until their own migrations are complete:
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.
Junction relations in 10.x
Raw viaTable() calls are rejected because a table-name string cannot identify soft-delete behavior. Use an explicit junction ActiveRecord class:
using() derives the table from Response::tableName(). When the junction extends MyActiveRecord and logical deletion is enabled, its deleted_at IS NULL condition is added automatically.
Migrating an app module to 9.x
Migrate one app module or table group at a time.
- Update the module package constraint to allow
andmemasin/yii2-myabstract:^9. -
Add a DB migration that renames the columns:
- Convert active rows to the new Laravel-style soft-delete state:
Use dateTime(6) for this migration phase unless the module explicitly decides to also take on timezone semantics changes. Do not convert to UNIX integer timestamps.
- Replace indexes that include
user_closedwith equivalent indexes usingdeleted_at. - Remove old column-name overrides from migrated models.
- Keep explicit old-name overrides only on models whose tables are not migrated yet.
-
Search the module for direct references to old names and update queries/search models/tests:
- Run the module tests and PHPStan before release:
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.
Optional audit schema helper
MyAbstract provides andmemasin\myabstract\schema\AuditSchemaHelper for explicit schema maintenance in migrations or project-owned maintenance code.
It is not a console command and does not run automatically.
The helper only creates the current audit columns: created_by, updated_by, deleted_by, created_at, updated_at, and deleted_at.
It never creates legacy columns: user_created, user_updated, user_closed, time_created, time_updated, or time_closed.
The user table and auth/runtime tables are skipped by default. Old-column renames are still the owning module's migration responsibility.