refactor: 处理优化migration文件与model文件字段不一致
This commit is contained in:
30
database/seeds/ProductAttrInit.php
Normal file
30
database/seeds/ProductAttrInit.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Seeder;
|
||||
|
||||
class ProductAttrInit extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run Method.
|
||||
*
|
||||
* Write your database seeder using this method.
|
||||
*
|
||||
* More information on writing seeders is available here:
|
||||
* http://docs.phinx.org/en/latest/seeding.html
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$data = [
|
||||
['id' => 1, 'language_id' => 1, 'attr_type' => 1, 'attr_name' => '颜色', 'is_system' => 1, 'created_at' => '2025-02-12 10:11:05', 'updated_at' => '2025-03-28 16:17:46', 'deleted_at' => null],
|
||||
['id' => 2, 'language_id' => 2, 'attr_type' => 1, 'attr_name' => 'Color', 'is_system' => 1, 'created_at' => '2025-02-12 10:11:05', 'updated_at' => '2025-05-26 11:08:55', 'deleted_at' => null]
|
||||
];
|
||||
|
||||
$table = $this->table('product_attr');
|
||||
|
||||
// empty the table
|
||||
$table->truncate();
|
||||
|
||||
// insert data
|
||||
$table->insert($data)->saveData();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user