aboutsummaryrefslogtreecommitdiff
path: root/database
diff options
context:
space:
mode:
Diffstat (limited to 'database')
-rw-r--r--database/migrations/2021_08_02_000000_create_rates_table.php65
1 files changed, 65 insertions, 0 deletions
diff --git a/database/migrations/2021_08_02_000000_create_rates_table.php b/database/migrations/2021_08_02_000000_create_rates_table.php
new file mode 100644
index 0000000..c6925d0
--- /dev/null
+++ b/database/migrations/2021_08_02_000000_create_rates_table.php
@@ -0,0 +1,65 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateRatesTable extends Migration
+{
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up()
+ {
+ Schema::create('currency', function (Blueprint $table) {
+ $table->id();
+ $table->string('name');
+ $table->string('unit');
+ $table->string('description')->nullable();
+ $table->timestamps();
+ });
+
+ Schema::create('rates', function (Blueprint $table) {
+ $table->id();
+ $table->unsignedBigInteger('currency_id');
+ $table->foreign('currency_id')->references('id')->on('currency');
+ $table->unsignedBigInteger('relative_id');
+ $table->foreign('relative_id')->references('id')->on('currency');
+ $table->float('value');
+ $table->timestamps();
+ });
+ DB::table('currency')->insert(
+ array(
+ 'name' => 'Bitcoin',
+ 'unit' => 'BTC',
+ 'description' => 'Created by Satoshi'
+ )
+ );
+ DB::table('currency')->insert(
+ array(
+ 'name' => 'US Dollar',
+ 'unit' => '$',
+ 'description' => 'Destroyed by Breton Woods'
+ )
+ );
+ DB::table('rates')->insert(
+ array(
+ 'currency_id' => 1,
+ 'relative_id' => 2,
+ 'value' => 100000.00
+ ));
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('coins');
+ Schema::dropIfExists('rates');
+ }
+}