| 1 |
<?php |
| 2 |
|
| 3 |
namespace Pinova; |
| 4 |
|
| 5 |
use Illuminate\Database\Schema\Blueprint; |
| 6 |
use Nabik_Net_Database; |
| 7 |
|
| 8 |
class Install extends \Nabik\Utils\V1\Install { |
| 9 |
|
| 10 |
public function tasks() { |
| 11 |
self::create_tables(); |
| 12 |
} |
| 13 |
|
| 14 |
public static function create_tables() { |
| 15 |
|
| 16 |
try { |
| 17 |
Nabik_Net_Database::Schema()->table( 'users', function ( Blueprint $table ) { |
| 18 |
$table->unique( 'user_login', 'user_login_pinova_unique' ); |
| 19 |
} ); |
| 20 |
} catch ( \Exception $e ) { |
| 21 |
} |
| 22 |
|
| 23 |
if ( ! Nabik_Net_Database::Schema()->hasTable( 'pinova_otp' ) ) { |
| 24 |
|
| 25 |
Nabik_Net_Database::Schema()->create( 'pinova_otp', function ( Blueprint $table ) { |
| 26 |
$table->bigIncrements( 'id' ); |
| 27 |
$table->foreignId( 'user_id' )->nullable(); |
| 28 |
$table->string( 'identifier' ); |
| 29 |
$table->string( 'code' ); |
| 30 |
$table->ipAddress( 'ip_address' )->index(); |
| 31 |
$table->unsignedTinyInteger( 'attempts' )->default( 0 ); |
| 32 |
$table->string( 'type', 25 ); |
| 33 |
$table->json( 'channels' ); |
| 34 |
$table->timestamp( 'expires_at' )->nullable(); |
| 35 |
$table->timestamp( 'verified_at' )->nullable(); |
| 36 |
$table->index( [ 'identifier', 'expires_at' ] ); |
| 37 |
} ); |
| 38 |
|
| 39 |
} |
| 40 |
|
| 41 |
if ( ! Nabik_Net_Database::Schema()->hasTable( 'pinova_blocks' ) ) { |
| 42 |
|
| 43 |
Nabik_Net_Database::Schema()->create( 'pinova_blocks', function ( Blueprint $table ) { |
| 44 |
$table->bigIncrements( 'id' ); |
| 45 |
$table->string( 'identifier' )->unique(); |
| 46 |
$table->foreignId( 'blocked_by' )->nullable(); |
| 47 |
$table->timestamp( 'blocked_until' )->nullable(); |
| 48 |
} ); |
| 49 |
|
| 50 |
} |
| 51 |
|
| 52 |
} |
| 53 |
|
| 54 |
} |