1: <?php
2:
3: use Illuminate\Database\Schema\Blueprint;
4: use Illuminate\Database\Migrations\Migration;
5:
6: class CreateFieldsTable extends Migration {
7:
8: /**
9: * Run the migrations.
10: *
11: * @access public
12: * @return void
13: */
14: public function up()
15: {
16: if (!Schema::hasTable('_db_fields'))
17: {
18:
19: Schema::create('_db_fields', function ($table)
20: {
21: $table->increments('id')->unique();
22: $table->string('name', 100); // the field's name
23: $table->string('fullname', 100); // the field's fully qualified name table.field
24: $table->string('label', 100); // the label
25: $table->integer('display_type_id')->nullable(); // how the field will be displayed in lists/selects (see _db_display_types table)
26: $table->integer('searchable')->nullable(); // 1 if the field is display in a search form, else 0
27: $table->integer('display_order')->nullable(); // the order in which field will be displayed in lists/selects
28: $table->string('type', 100)->nullable(); // datatype
29: $table->integer('length')->nullable(); // datalength
30: $table->integer('width')->nullable(); // display width of the field in pixels
31: $table->integer('widget_type_id')->nullable(); // an html widget (see _db_widget_types table)
32: $table->string('null', 3)->nullable(); // nullable
33: $table->string('key', 50)->nullable(); // type of key
34: $table->string('default', 100)->nullable(); // default value
35: $table->string('extra', 100)->nullable();
36: $table->string('href', 100)->nullable(); //hyperlink this field with the href link
37: $table->integer('table_id')->unsigned(); // links to _db_tables.id
38: // $table->integer('pk_field_id')->unsigned()->nullable(); // links to _db_fields.id (the id of the primary key)
39: // $table->integer('pk_display_field_id')->unsigned()->nullable(); // links to _db_fields.id (the id of a field in the primary table that will be used as a description of the primary key id)
40: $table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));
41: $table->timestamp('updated_at')->default('0000-00-00 00:00:00');
42:
43: /*
44: $table->unique(array('table_id', 'name'));
45: $table->foreign('table_id')->references('id')->on('_db_tables')->onDelete('cascade');
46: */
47: });
48: }
49: }
50:
51: /**
52: * Reverse the migrations.
53: *
54: * @access public
55: * @return void
56: */
57: public function down()
58: {
59: Schema::dropIfExists('_db_fields');
60: }
61:
62: }
63: