You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.4 KiB

  1. <?php
  2. use Illuminate\Database\Schema\Blueprint;
  3. use Illuminate\Database\Migrations\Migration;
  4. class Setup extends Migration
  5. {
  6. /**
  7. * Run the migrations.
  8. *
  9. * @return void
  10. */
  11. public function up()
  12. {
  13. Schema::create('databases', function (Blueprint $table) {
  14. $table->increments('id');
  15. $table->string('name', 100);
  16. $table->string('read_token', 255);
  17. $table->string('write_token', 255);
  18. $table->unsignedInteger('created_by');
  19. $table->datetime('created_at');
  20. $table->unique(['read_token','write_token']);
  21. });
  22. Schema::create('users', function (Blueprint $table) {
  23. $table->increments('id');
  24. $table->string('url', 255);
  25. $table->datetime('created_at')->nullable();
  26. $table->datetime('last_login')->nullable();
  27. });
  28. Schema::create('database_users', function (Blueprint $table) {
  29. $table->unsignedInteger('database_id');
  30. $table->unsignedInteger('user_id');
  31. $table->datetime('created_at')->nullable();
  32. $table->primary(['database_id','user_id']);
  33. });
  34. }
  35. /**
  36. * Reverse the migrations.
  37. *
  38. * @return void
  39. */
  40. public function down()
  41. {
  42. Schema::drop('users');
  43. Schema::drop('databases');
  44. Schema::drop('database_users');
  45. }
  46. }