Add migration to create default site and test user
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -306,6 +306,11 @@
|
|||||||
"created_at": "2025-11-19T05:40:00+00:00",
|
"created_at": "2025-11-19T05:40:00+00:00",
|
||||||
"created_by": "root",
|
"created_by": "root",
|
||||||
"command": "php artisan make:migration:safe rename_system_tables_to_underscore_prefix"
|
"command": "php artisan make:migration:safe rename_system_tables_to_underscore_prefix"
|
||||||
|
},
|
||||||
|
"2025_11_19_231708_create_test_user_record.php": {
|
||||||
|
"created_at": "2025-11-19T23:17:08+00:00",
|
||||||
|
"created_by": "root",
|
||||||
|
"command": "php artisan make:migration:safe create_test_user_record"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
65
database/migrations/2025_11_19_231708_create_test_user_record.php
Executable file
65
database/migrations/2025_11_19_231708_create_test_user_record.php
Executable file
@@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* Creates a default site and user record for the test user.
|
||||||
|
*
|
||||||
|
* Assumptions:
|
||||||
|
* - Running in fresh/reset database
|
||||||
|
* - login_users table has record with id=1 (created by prior migration)
|
||||||
|
* - sites table is empty
|
||||||
|
* - users table is empty
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
// Create default site
|
||||||
|
DB::statement("
|
||||||
|
INSERT INTO sites (
|
||||||
|
id,
|
||||||
|
slug,
|
||||||
|
name,
|
||||||
|
is_enabled,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
) VALUES (
|
||||||
|
1,
|
||||||
|
'test',
|
||||||
|
'Test Site',
|
||||||
|
1,
|
||||||
|
NOW(3),
|
||||||
|
NOW(3)
|
||||||
|
)
|
||||||
|
");
|
||||||
|
|
||||||
|
// Create user record for test user and associate with site
|
||||||
|
DB::statement("
|
||||||
|
INSERT INTO users (
|
||||||
|
id,
|
||||||
|
login_user_id,
|
||||||
|
site_id,
|
||||||
|
email,
|
||||||
|
first_name,
|
||||||
|
last_name,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
) VALUES (
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
'test@example.com',
|
||||||
|
'Test',
|
||||||
|
'User',
|
||||||
|
NOW(3),
|
||||||
|
NOW(3)
|
||||||
|
)
|
||||||
|
");
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user