Skip to content

Commit

Permalink
Publish migration instead of loading it
Browse files Browse the repository at this point in the history
  • Loading branch information
alexblunck committed Sep 6, 2018
1 parent cabe8c4 commit 0bee147
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 40 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ composer require blunck/coupons
The package includes a migration to create a `coupons` & `coupon_user` table:

```bash
# Publish migration file
php artisan vendor:publish --provider="Blunck\Coupons\CouponServiceProvider"

# Run migration
php artisan migrate
```

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ public function up()
$table->unsignedInteger('coupon_id');

$table->primary(['user_id', 'coupon_id']);
$table->foreign('user_id')->references('id')->on('users');

$table->foreign('user_id')
->references('id')->on('users')
->onDelete('cascade');

$table->foreign('coupon_id')->references('id')->on('coupons');
});
}
Expand Down
4 changes: 3 additions & 1 deletion src/CouponServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ class CouponServiceProvider extends ServiceProvider
*/
public function boot()
{
$this->loadMigrationsFrom(__DIR__.'/../migrations');
$this->publishes([
__DIR__.'/../migrations/create_coupons_table.php.stub' => database_path('migrations/'.date('Y_m_d_His', time()).'_create_coupons_table.php'),
], 'migrations');
}

/**
Expand Down

0 comments on commit 0bee147

Please sign in to comment.