Skip to content

Commit

Permalink
Add nullable and fix more migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
dmohns committed Nov 18, 2024
1 parent 7d82f4b commit b0e184f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function up(): void
Schema::connection('shard')->create('asset_types', static function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->integer('price')->unsigned();
$table->integer('price')->unsigned()->nullable();
$table->timestamps();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public function up()
$table->integer('zoom');
$table->double('latitude', 10);
$table->double('longitude', 10);
$table->string('provider');
$table->string('bingMapApiKey');
$table->string('provider')->nullable();
$table->string('bingMapApiKey')->nullable();
$table->timestamps();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function up()
Type::addType('double', FloatType::class);
}
Schema::connection('shard')->table('asset_types', function (Blueprint $table) {
$table->double('price', 15, 6)->change();
$table->double('price', 15, 6)->nullable()->change();
});
}

Expand All @@ -30,6 +30,7 @@ public function up()
public function down()
{
Schema::connection('shard')->table('asset_types', function (Blueprint $table) {
$table->integer('price')->unsigned()->nullable()->change();
});
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ public function up()
{
Schema::connection('shard')->table('asset_types', function (Blueprint $table) {
$table->dropColumn('price');
$table->dropColumn('default_rate');
});
Schema::connection('shard')->table('assets', function (Blueprint $table) {
$table->renameColumn('default_price', 'price');
$table->dropColumn('default_rate');
});
Schema::connection('shard')->table('asset_people', function (Blueprint $table) {
$table->renameColumn('asset_type_id', 'asset_id');
Expand All @@ -34,5 +34,18 @@ public function up()
*/
public function down()
{
Schema::connection('shard')->table('agent_assigned_appliances', function (Blueprint $table) {
$table->renameColumn('appliance_id', 'appliance_type_id');
});
Schema::connection('shard')->table('asset_people', function (Blueprint $table) {
$table->renameColumn('asset_id', 'asset_type_id');
});
Schema::connection('shard')->table('assets', function (Blueprint $table) {
$table->renameColumn('price', 'default_price');
});
Schema::connection('shard')->table('asset_types', function (Blueprint $table) {
$table->double('price', 15, 6)->nullable();
$table->integer('default_rate');
});
}
};

0 comments on commit b0e184f

Please sign in to comment.