chore: init saasshop repo + sql migrations runner + gitee go
This commit is contained in:
52
database/migrations/0001_01_01_000000_create_users_table.php
Normal file
52
database/migrations/0001_01_01_000000_create_users_table.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('merchant_id')->nullable()->index();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->string('phone', 30)->nullable();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->string('status', 30)->default('active');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||
$table->string('email')->primary();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->foreignId('user_id')->nullable()->index();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->longText('payload');
|
||||
$table->integer('last_activity')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
Schema::dropIfExists('password_reset_tokens');
|
||||
Schema::dropIfExists('sessions');
|
||||
}
|
||||
};
|
||||
35
database/migrations/0001_01_01_000001_create_cache_table.php
Normal file
35
database/migrations/0001_01_01_000001_create_cache_table.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('cache', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->mediumText('value');
|
||||
$table->integer('expiration')->index();
|
||||
});
|
||||
|
||||
Schema::create('cache_locks', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->string('owner');
|
||||
$table->integer('expiration')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('cache');
|
||||
Schema::dropIfExists('cache_locks');
|
||||
}
|
||||
};
|
||||
57
database/migrations/0001_01_01_000002_create_jobs_table.php
Normal file
57
database/migrations/0001_01_01_000002_create_jobs_table.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedTinyInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
});
|
||||
|
||||
Schema::create('job_batches', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->string('name');
|
||||
$table->integer('total_jobs');
|
||||
$table->integer('pending_jobs');
|
||||
$table->integer('failed_jobs');
|
||||
$table->longText('failed_job_ids');
|
||||
$table->mediumText('options')->nullable();
|
||||
$table->integer('cancelled_at')->nullable();
|
||||
$table->integer('created_at');
|
||||
$table->integer('finished_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('uuid')->unique();
|
||||
$table->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('jobs');
|
||||
Schema::dropIfExists('job_batches');
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('merchants', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('slug')->unique();
|
||||
$table->string('domain')->nullable()->unique();
|
||||
$table->string('contact_name')->nullable();
|
||||
$table->string('contact_phone', 30)->nullable();
|
||||
$table->string('contact_email')->nullable();
|
||||
$table->string('plan', 50)->default('basic');
|
||||
$table->string('status', 30)->default('active');
|
||||
$table->timestamp('trial_ends_at')->nullable();
|
||||
$table->timestamp('activated_at')->nullable();
|
||||
$table->json('settings')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('merchants');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('admins', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('merchant_id')->nullable()->constrained('merchants')->nullOnDelete();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->string('phone', 30)->nullable();
|
||||
$table->string('password');
|
||||
$table->string('role', 30)->default('owner');
|
||||
$table->string('status', 30)->default('active');
|
||||
$table->timestamp('last_login_at')->nullable();
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('admins');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('orders', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('merchant_id')->constrained('merchants')->cascadeOnDelete();
|
||||
$table->foreignId('user_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->string('order_no', 50)->unique();
|
||||
$table->string('status', 30)->default('pending');
|
||||
$table->decimal('product_amount', 10, 2)->default(0);
|
||||
$table->decimal('discount_amount', 10, 2)->default(0);
|
||||
$table->decimal('shipping_amount', 10, 2)->default(0);
|
||||
$table->decimal('pay_amount', 10, 2)->default(0);
|
||||
$table->string('buyer_name')->nullable();
|
||||
$table->string('buyer_phone', 30)->nullable();
|
||||
$table->string('buyer_email')->nullable();
|
||||
$table->text('remark')->nullable();
|
||||
$table->timestamp('paid_at')->nullable();
|
||||
$table->timestamp('shipped_at')->nullable();
|
||||
$table->timestamp('completed_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('orders');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('products', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('merchant_id')->constrained('merchants')->cascadeOnDelete();
|
||||
$table->string('title');
|
||||
$table->string('slug');
|
||||
$table->string('sku', 80)->unique();
|
||||
$table->text('summary')->nullable();
|
||||
$table->longText('content')->nullable();
|
||||
$table->decimal('price', 10, 2)->default(0);
|
||||
$table->decimal('original_price', 10, 2)->nullable();
|
||||
$table->integer('stock')->default(0);
|
||||
$table->string('status', 30)->default('draft');
|
||||
$table->json('images')->nullable();
|
||||
$table->timestamps();
|
||||
$table->unique(['merchant_id', 'slug']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('products');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('register_source', 30)->default('pc')->after('status');
|
||||
$table->string('last_login_source', 30)->nullable()->after('register_source');
|
||||
$table->string('wechat_openid', 64)->nullable()->after('last_login_source');
|
||||
$table->string('wechat_unionid', 64)->nullable()->after('wechat_openid');
|
||||
$table->string('mini_openid', 64)->nullable()->after('wechat_unionid');
|
||||
});
|
||||
|
||||
Schema::table('orders', function (Blueprint $table) {
|
||||
$table->string('platform', 30)->default('pc')->after('status');
|
||||
$table->string('payment_channel', 30)->nullable()->after('platform');
|
||||
$table->string('payment_status', 30)->default('unpaid')->after('payment_channel');
|
||||
$table->string('device_type', 30)->nullable()->after('payment_status');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn(['register_source', 'last_login_source', 'wechat_openid', 'wechat_unionid', 'mini_openid']);
|
||||
});
|
||||
|
||||
Schema::table('orders', function (Blueprint $table) {
|
||||
$table->dropColumn(['platform', 'payment_channel', 'payment_status', 'device_type']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('oauth_accounts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->foreignId('merchant_id')->nullable()->constrained('merchants')->nullOnDelete();
|
||||
$table->string('platform', 30);
|
||||
$table->string('provider', 30);
|
||||
$table->string('openid', 100)->nullable();
|
||||
$table->string('unionid', 100)->nullable();
|
||||
$table->string('app_id', 100)->nullable();
|
||||
$table->string('nickname')->nullable();
|
||||
$table->string('avatar')->nullable();
|
||||
$table->json('raw_payload')->nullable();
|
||||
$table->timestamps();
|
||||
$table->index(['platform', 'provider']);
|
||||
$table->unique(['provider', 'openid']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('oauth_accounts');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('system_configs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('config_key')->unique();
|
||||
$table->string('config_name');
|
||||
$table->text('config_value')->nullable();
|
||||
$table->string('value_type', 30)->default('string');
|
||||
$table->boolean('autoload')->default(true);
|
||||
$table->string('group', 50)->default('system')->index();
|
||||
$table->string('remark')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('system_configs');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('channel_configs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('channel_code', 50)->unique();
|
||||
$table->string('channel_name');
|
||||
$table->string('channel_type', 50)->default('sales');
|
||||
$table->string('status', 30)->default('enabled')->index();
|
||||
$table->string('entry_path')->nullable();
|
||||
$table->boolean('supports_login')->default(false);
|
||||
$table->boolean('supports_payment')->default(false);
|
||||
$table->boolean('supports_share')->default(false);
|
||||
$table->unsignedInteger('sort')->default(0);
|
||||
$table->json('settings')->nullable();
|
||||
$table->string('remark')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('channel_configs');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('payment_configs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('payment_code', 50)->unique();
|
||||
$table->string('payment_name');
|
||||
$table->string('provider', 50);
|
||||
$table->string('status', 30)->default('disabled')->index();
|
||||
$table->boolean('is_sandbox')->default(true);
|
||||
$table->boolean('supports_refund')->default(false);
|
||||
$table->json('settings')->nullable();
|
||||
$table->string('remark')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('payment_configs');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('product_categories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('merchant_id')->constrained('merchants')->cascadeOnDelete();
|
||||
$table->string('name');
|
||||
$table->string('slug');
|
||||
$table->string('status', 30)->default('active');
|
||||
$table->unsignedInteger('sort')->default(0);
|
||||
$table->text('description')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['merchant_id', 'slug']);
|
||||
});
|
||||
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->foreignId('category_id')->nullable()->after('merchant_id')->constrained('product_categories')->nullOnDelete();
|
||||
$table->index(['merchant_id', 'category_id']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('category_id');
|
||||
});
|
||||
|
||||
Schema::dropIfExists('product_categories');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('order_items', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('merchant_id')->constrained('merchants')->cascadeOnDelete();
|
||||
$table->foreignId('order_id')->constrained('orders')->cascadeOnDelete();
|
||||
$table->foreignId('product_id')->nullable()->constrained('products')->nullOnDelete();
|
||||
$table->string('product_title');
|
||||
$table->string('product_sku', 80)->nullable();
|
||||
$table->decimal('product_price', 10, 2)->default(0);
|
||||
$table->unsignedInteger('quantity')->default(1);
|
||||
$table->decimal('line_total_amount', 10, 2)->default(0);
|
||||
$table->json('snapshot')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['merchant_id', 'order_id']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('order_items');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('product_import_histories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('scope', 30);
|
||||
$table->foreignId('merchant_id')->nullable()->constrained('merchants')->nullOnDelete();
|
||||
$table->foreignId('admin_id')->nullable()->constrained('admins')->nullOnDelete();
|
||||
$table->string('file_name');
|
||||
$table->unsignedInteger('success_count')->default(0);
|
||||
$table->unsignedInteger('failed_count')->default(0);
|
||||
$table->string('failure_file')->nullable();
|
||||
$table->timestamp('imported_at');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['scope', 'imported_at']);
|
||||
$table->index(['merchant_id', 'imported_at']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('product_import_histories');
|
||||
}
|
||||
};
|
||||
31
database/migrations/2026_03_10_000100_create_plans_table.php
Normal file
31
database/migrations/2026_03_10_000100_create_plans_table.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('plans', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('code', 50)->unique();
|
||||
$table->string('name', 100);
|
||||
$table->string('billing_cycle', 30)->default('monthly');
|
||||
$table->decimal('price', 10, 2)->default(0);
|
||||
$table->decimal('list_price', 10, 2)->default(0);
|
||||
$table->string('status', 30)->default('active');
|
||||
$table->unsignedInteger('sort')->default(0);
|
||||
$table->text('description')->nullable();
|
||||
$table->json('settings')->nullable();
|
||||
$table->timestamp('published_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('plans');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('site_subscriptions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('merchant_id')->constrained('merchants')->cascadeOnDelete();
|
||||
$table->foreignId('plan_id')->nullable()->constrained('plans')->nullOnDelete();
|
||||
$table->string('status', 30)->default('pending');
|
||||
$table->string('source', 30)->default('manual');
|
||||
$table->string('subscription_no', 50)->unique();
|
||||
$table->string('plan_name', 100)->nullable();
|
||||
$table->string('billing_cycle', 30)->nullable();
|
||||
$table->unsignedInteger('period_months')->default(1);
|
||||
$table->decimal('amount', 10, 2)->default(0);
|
||||
$table->timestamp('starts_at')->nullable();
|
||||
$table->timestamp('ends_at')->nullable();
|
||||
$table->timestamp('trial_ends_at')->nullable();
|
||||
$table->timestamp('activated_at')->nullable();
|
||||
$table->timestamp('cancelled_at')->nullable();
|
||||
$table->json('snapshot')->nullable();
|
||||
$table->json('meta')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['merchant_id', 'status']);
|
||||
$table->index(['plan_id', 'status']);
|
||||
$table->index('ends_at');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('site_subscriptions');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('platform_orders', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('merchant_id')->constrained('merchants')->cascadeOnDelete();
|
||||
$table->foreignId('plan_id')->nullable()->constrained('plans')->nullOnDelete();
|
||||
$table->foreignId('site_subscription_id')->nullable()->constrained('site_subscriptions')->nullOnDelete();
|
||||
$table->foreignId('created_by_admin_id')->nullable()->constrained('admins')->nullOnDelete();
|
||||
$table->string('order_no', 50)->unique();
|
||||
$table->string('order_type', 30)->default('new_purchase');
|
||||
$table->string('status', 30)->default('pending');
|
||||
$table->string('payment_status', 30)->default('unpaid');
|
||||
$table->string('payment_channel', 30)->nullable();
|
||||
$table->string('plan_name', 100)->nullable();
|
||||
$table->string('billing_cycle', 30)->nullable();
|
||||
$table->unsignedInteger('period_months')->default(1);
|
||||
$table->unsignedInteger('quantity')->default(1);
|
||||
$table->decimal('list_amount', 10, 2)->default(0);
|
||||
$table->decimal('discount_amount', 10, 2)->default(0);
|
||||
$table->decimal('payable_amount', 10, 2)->default(0);
|
||||
$table->decimal('paid_amount', 10, 2)->default(0);
|
||||
$table->timestamp('placed_at')->nullable();
|
||||
$table->timestamp('paid_at')->nullable();
|
||||
$table->timestamp('activated_at')->nullable();
|
||||
$table->timestamp('cancelled_at')->nullable();
|
||||
$table->timestamp('refunded_at')->nullable();
|
||||
$table->json('plan_snapshot')->nullable();
|
||||
$table->json('meta')->nullable();
|
||||
$table->text('remark')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['merchant_id', 'status']);
|
||||
$table->index(['payment_status', 'status']);
|
||||
$table->index(['plan_id', 'status']);
|
||||
$table->index('placed_at');
|
||||
$table->index('paid_at');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('platform_orders');
|
||||
}
|
||||
};
|
||||
3
database/migrations/V1__baseline.sql
Normal file
3
database/migrations/V1__baseline.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
-- V1 baseline
|
||||
-- 说明:用于初始化 SQL 迁移体系的基线版本。
|
||||
-- 注意:本文件不做任何结构变更,仅作为版本占位。
|
||||
Reference in New Issue
Block a user