feat: 国家seeder

This commit is contained in:
2025-06-12 16:00:08 +08:00
parent 0d4cab76ef
commit 823c7a2d38

View File

@@ -0,0 +1,30 @@
<?php
use think\migration\Seeder;
class SysCountryInit 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, "name" => "中国", "en_name" => "China", "code" => "ZH", "icon" => null, "status" => 1, "sort" => 1, "created_at" => "2025-01-04 14:04:27", "updated_at" => "2025-03-14 11:52:17"],
["id" => 2, "name" => "美国", "en_name" => "USA", "code" => "US", "icon" => null, "status" => 1, "sort" => 2, "created_at" => "2025-03-25 13:45:51", "updated_at" => "2025-04-07 11:54:43"]
];
$table = $this->table('sys_country');
// empty the table
$table->truncate();
// insert data
$table->insert($data)->saveData();
}
}