-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
69 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,28 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of nodeloc/lottery. | ||
* | ||
* Copyright (c) Nodeloc. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use Flarum\Database\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
|
||
return Migration::createTable('lotteries', function (Blueprint $table) { | ||
$table->increments('id'); | ||
|
||
$table->string('question'); | ||
|
||
$table->string('prizes')->comment('奖品'); | ||
$table->integer('price')->nullable()->comment('参与价格'); | ||
$table->integer('amount')->comment('数量'); | ||
$table->timestamp('end_date')->nullable()->comment('开奖日期'); | ||
$table->integer('post_id')->unsigned(); | ||
$table->integer('user_id')->unsigned()->nullable(); | ||
$table->integer('vote_count')->unsigned(); | ||
$table->integer('max_votes')->unsigned(); | ||
|
||
$table->boolean('allow_multiple_votes'); | ||
|
||
|
||
$table->boolean('public_lottery'); | ||
$table->integer('min_participants')->unsigned()->comment('最少人数'); | ||
$table->integer('max_participants')->unsigned()->comment('最多人数'); | ||
$table->integer('enter_count')->default(0); | ||
$table->boolean('can_cancel_enter')->nullable(); | ||
$table->tinyInteger('status')->comment('0:已发布 1:已开奖 2:到期人数不够取消'); | ||
$table->json('settings'); | ||
$table->timestamp('end_date')->nullable(); | ||
$table->timestamps(); | ||
|
||
$table->primary('id'); | ||
$table->index('user_id'); | ||
$table->index('post_id'); | ||
|
||
$table->foreign('post_id')->references('id')->on('posts')->onDelete('cascade'); | ||
$table->foreign('user_id')->references('id')->on('users')->onDelete('set null'); | ||
}); |
27 changes: 10 additions & 17 deletions
27
migrations/2024_01_31_000001_add_lottery_options_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,20 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of nodeloc/lottery. | ||
* | ||
* Copyright (c) Nodeloc. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use Flarum\Database\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
|
||
return Migration::createTable('lottery_options', function (Blueprint $table) { | ||
$table->increments('id'); | ||
|
||
$table->string('answer'); | ||
|
||
$table->integer('lottery_id')->unsigned(); | ||
$table->integer('vote_count')->unsigned(); | ||
$table->string('image_url'); | ||
|
||
$table->string('operator_type', 256)->comment('运算类型'); | ||
$table->unsignedInteger('lottery_id'); | ||
$table->unsignedTinyInteger('operator')->comment('0 等于 1 小于等于 2 大于等于'); | ||
$table->integer('operator_value')->comment('数值'); | ||
$table->timestamps(); | ||
|
||
$table->foreign('lottery_id')->references('id')->on('lotteries')->onDelete('cascade'); | ||
$table->index('lottery_id'); | ||
|
||
$table->foreign('lottery_id') | ||
->references('id') | ||
->on('lotteries') | ||
->onDelete('cascade'); | ||
}); |
25 changes: 25 additions & 0 deletions
25
migrations/2024_01_31_000002_add_lottery_participants_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
use Flarum\Database\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
|
||
return Migration::createTable('lottery_participants', function (Blueprint $table) { | ||
$table->increments('id'); | ||
$table->unsignedInteger('lottery_id'); | ||
$table->unsignedTinyInteger('status')->comment('0 未中奖 1中奖'); | ||
$table->unsignedInteger('user_id')->nullable(); | ||
$table->timestamps(); | ||
|
||
$table->index('lottery_id'); | ||
$table->index('user_id'); | ||
|
||
$table->foreign('lottery_id') | ||
->references('id') | ||
->on('lotteries') | ||
->onDelete('cascade'); | ||
|
||
$table->foreign('user_id') | ||
->references('id') | ||
->on('users') | ||
->onDelete('set null'); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters