master
lion 2 months ago
parent e5e221a61d
commit 35d7698601

@ -58,7 +58,7 @@ class ActivityController extends Controller
'start_at' => ['nullable', 'date'],
'end_at' => ['nullable', 'date'],
'address' => ['nullable', 'string', 'max:255'],
'contact_phone' => ['nullable', 'string', 'max:20'],
'contact_phone' => ['nullable', 'string', 'max:64'],
'lat' => ['nullable', 'numeric'],
'lng' => ['nullable', 'numeric'],
'detail_html' => ['nullable', 'string'],
@ -113,7 +113,7 @@ class ActivityController extends Controller
'start_at' => ['nullable', 'date'],
'end_at' => ['nullable', 'date'],
'address' => ['nullable', 'string', 'max:255'],
'contact_phone' => ['nullable', 'string', 'max:20'],
'contact_phone' => ['nullable', 'string', 'max:64'],
'lat' => ['nullable', 'numeric'],
'lng' => ['nullable', 'numeric'],
'detail_html' => ['nullable', 'string'],

@ -27,14 +27,14 @@ class VenueController extends Controller
'ticket_type' => ['nullable', 'string', 'max:80'],
'appointment_type' => ['nullable', 'string', 'max:40'],
'open_mode' => ['nullable', 'string', 'max:40', Rule::in(['fulltime', 'scheduled', 'appointment'])],
'open_time' => ['nullable', 'string', 'max:120'],
'open_time' => ['nullable', 'string', 'max:65535'],
'reservation_notice' => ['nullable', 'string'],
'ticket_content' => ['nullable', 'string'],
'booking_method' => ['nullable', 'string'],
'visit_form' => ['nullable', 'string'],
'consultation_hours' => ['nullable', 'string'],
'address' => ['nullable', 'string', 'max:255'],
'contact_phone' => ['nullable', 'string', 'max:20'],
'contact_phone' => ['nullable', 'string', 'max:64'],
'lat' => ['nullable', 'numeric'],
'lng' => ['nullable', 'numeric'],
'cover_image' => ['nullable', 'string', 'max:255'],
@ -139,14 +139,14 @@ class VenueController extends Controller
'ticket_type' => ['nullable', 'string', 'max:80'],
'appointment_type' => ['nullable', 'string', 'max:40'],
'open_mode' => ['nullable', 'string', 'max:40', Rule::in(['fulltime', 'scheduled', 'appointment'])],
'open_time' => ['nullable', 'string', 'max:120'],
'open_time' => ['nullable', 'string', 'max:65535'],
'reservation_notice' => ['nullable', 'string'],
'ticket_content' => ['nullable', 'string'],
'booking_method' => ['nullable', 'string'],
'visit_form' => ['nullable', 'string'],
'consultation_hours' => ['nullable', 'string'],
'address' => ['nullable', 'string', 'max:255'],
'contact_phone' => ['nullable', 'string', 'max:20'],
'contact_phone' => ['nullable', 'string', 'max:64'],
'lat' => ['nullable', 'numeric'],
'lng' => ['nullable', 'numeric'],
'cover_image' => ['nullable', 'string', 'max:255'],

@ -300,7 +300,7 @@ class VenueImportService
'ticket_type' => ['nullable', 'string', 'max:80'],
'appointment_type' => ['nullable', 'string', 'max:40'],
'open_mode' => ['nullable', 'string', 'max:40'],
'open_time' => ['nullable', 'string', 'max:120'],
'open_time' => ['nullable', 'string', 'max:65535'],
'ticket_content' => ['nullable', 'string'],
'booking_method' => ['nullable', 'string'],
'visit_form' => ['nullable', 'string'],
@ -308,7 +308,7 @@ class VenueImportService
'detail_html' => ['nullable', 'string'],
'reservation_notice' => ['nullable', 'string'],
'address' => ['nullable', 'string', 'max:255'],
'contact_phone' => ['nullable', 'string', 'max:20'],
'contact_phone' => ['nullable', 'string', 'max:64'],
'lat' => ['nullable', 'numeric'],
'lng' => ['nullable', 'numeric'],
'sort' => ['nullable', 'integer', 'min:0'],

@ -0,0 +1,54 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
if (! Schema::hasColumn('venues', 'contact_phone') || ! Schema::hasColumn('activities', 'contact_phone')) {
return;
}
$driver = Schema::getConnection()->getDriverName();
if ($driver === 'mysql') {
DB::statement('ALTER TABLE `venues` MODIFY `contact_phone` VARCHAR(64) NULL');
DB::statement('ALTER TABLE `activities` MODIFY `contact_phone` VARCHAR(64) NULL');
return;
}
if ($driver === 'pgsql') {
DB::statement('ALTER TABLE venues ALTER COLUMN contact_phone TYPE VARCHAR(64)');
DB::statement('ALTER TABLE activities ALTER COLUMN contact_phone TYPE VARCHAR(64)');
return;
}
// sqlite 等对长度约束较宽松,列已存在时可不改;新环境仍以迁移定义为准
}
public function down(): void
{
if (! Schema::hasColumn('venues', 'contact_phone') || ! Schema::hasColumn('activities', 'contact_phone')) {
return;
}
$driver = Schema::getConnection()->getDriverName();
if ($driver === 'mysql') {
DB::statement('ALTER TABLE `venues` MODIFY `contact_phone` VARCHAR(20) NULL');
DB::statement('ALTER TABLE `activities` MODIFY `contact_phone` VARCHAR(20) NULL');
return;
}
if ($driver === 'pgsql') {
DB::statement('ALTER TABLE venues ALTER COLUMN contact_phone TYPE VARCHAR(20)');
DB::statement('ALTER TABLE activities ALTER COLUMN contact_phone TYPE VARCHAR(20)');
}
}
};

@ -0,0 +1,48 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
if (! Schema::hasColumn('venues', 'open_time')) {
return;
}
$driver = Schema::getConnection()->getDriverName();
if ($driver === 'mysql') {
DB::statement('ALTER TABLE `venues` MODIFY `open_time` TEXT NULL');
return;
}
if ($driver === 'pgsql') {
DB::statement('ALTER TABLE venues ALTER COLUMN open_time TYPE TEXT');
return;
}
}
public function down(): void
{
if (! Schema::hasColumn('venues', 'open_time')) {
return;
}
$driver = Schema::getConnection()->getDriverName();
if ($driver === 'mysql') {
DB::statement('ALTER TABLE `venues` MODIFY `open_time` VARCHAR(120) NULL');
return;
}
if ($driver === 'pgsql') {
DB::statement('ALTER TABLE venues ALTER COLUMN open_time TYPE VARCHAR(120)');
}
}
};
Loading…
Cancel
Save