2018_11_27_091146_create_transactions_table.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. // Copyright 2019 Hackware SpA <human@hackware.cl>
  3. // This file is part of "Hackware Web Services Wallet" and licensed under
  4. // the terms of the GNU Affero General Public License version 3, or (at your
  5. // option) a later version. You should have received a copy of this license
  6. // along with the software. If not, see <https://www.gnu.org/licenses/>.
  7. use Illuminate\Support\Facades\Schema;
  8. use Illuminate\Database\Schema\Blueprint;
  9. use Illuminate\Database\Migrations\Migration;
  10. class CreateTransactionsTable extends Migration
  11. {
  12. /**
  13. * Run the migrations.
  14. *
  15. * @return void
  16. */
  17. public function up()
  18. {
  19. Schema::create('transactions', function (Blueprint $table) {
  20. $table->increments('id');
  21. $table->string('wallet_uid', 100);
  22. $table->foreign('wallet_uid')
  23. ->references('uid')
  24. ->on('wallets')
  25. ->onUpdate('cascade')
  26. ->onDelete('restrict');
  27. $table->unsignedInteger('currency_id');
  28. $table->foreign('currency_id')
  29. ->references('id')
  30. ->on('currencies')
  31. ->onUpdate('restrict')
  32. ->onDelete('restrict');
  33. $table->decimal('amount', 16, 8);
  34. $table->string('comment', 255)->nullable();
  35. $table->timestamp('created_at')->nullable()->index();
  36. });
  37. }
  38. /**
  39. * Reverse the migrations.
  40. *
  41. * @return void
  42. */
  43. public function down()
  44. {
  45. Schema::dropIfExists('transactions');
  46. }
  47. }