1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Illuminate\Support\Facades\Schema; |
4
|
|
|
use Illuminate\Database\Migrations\Migration; |
5
|
|
|
|
6
|
|
|
class CreateColumnTypesTable extends Migration |
|
|
|
|
7
|
|
|
{ |
8
|
|
|
/** |
9
|
|
|
* Run the migrations. |
10
|
|
|
* |
11
|
|
|
* @return void |
12
|
|
|
*/ |
13
|
|
|
public function up() |
14
|
|
|
{ |
15
|
|
|
// uncomment the next statement to map strings to enum types in doctrine and get over the 'Unknown database type enum' DBAL error |
|
|
|
|
16
|
|
|
// Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string'); |
|
|
|
|
17
|
|
|
|
18
|
|
|
Schema::create('column_types', function ($table) { |
19
|
|
|
$table->bigInteger('bigIntegerCol'); |
20
|
|
|
$table->binary('binaryCol'); |
21
|
|
|
$table->boolean('booleanCol'); |
22
|
|
|
$table->char('charCol', 4); |
23
|
|
|
$table->date('dateCol'); |
24
|
|
|
$table->dateTime('dateTimeCol'); |
25
|
|
|
$table->dateTimeTz('dateTimeTzCol'); |
26
|
|
|
$table->decimal('decimalCol', 5, 2); |
27
|
|
|
$table->double('doubleCol', 15, 8); |
28
|
|
|
$table->enum('enumCol', ['foo', 'bar']); |
29
|
|
|
$table->float('floatCol'); |
30
|
|
|
$table->integer('integerCol'); |
31
|
|
|
$table->ipAddress('ipAddressCol'); |
32
|
|
|
$table->json('jsonCol'); |
33
|
|
|
$table->jsonb('jsonbCol'); |
34
|
|
|
$table->longText('longTextCol'); |
35
|
|
|
$table->macAddress('macAddressCol'); |
36
|
|
|
$table->mediumInteger('mediumIntegerCol'); |
37
|
|
|
$table->mediumText('mediumTextCol'); |
38
|
|
|
$table->smallInteger('smallIntegerCol'); |
39
|
|
|
$table->string('stringCol'); |
40
|
|
|
$table->text('textCol'); |
41
|
|
|
$table->time('timeCol'); |
42
|
|
|
$table->timeTz('timeTzCol'); |
43
|
|
|
$table->tinyInteger('tinyIntegerCol'); |
44
|
|
|
$table->timestamp('timestampCol'); |
45
|
|
|
$table->timestampTz('timestampTzCol')->nullable(); |
46
|
|
|
$table->uuid('uuidCol'); |
47
|
|
|
}); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Reverse the migrations. |
52
|
|
|
* |
53
|
|
|
* @return void |
54
|
|
|
*/ |
55
|
|
|
public function down() |
56
|
|
|
{ |
57
|
|
|
Schema::drop('column_types'); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.