summaryrefslogtreecommitdiff
path: root/ssh/database/migrations
diff options
context:
space:
mode:
Diffstat (limited to 'ssh/database/migrations')
-rw-r--r--ssh/database/migrations/2014_10_12_000000_create_users_table.php36
-rw-r--r--ssh/database/migrations/2014_10_12_100000_create_password_resets_table.php32
-rw-r--r--ssh/database/migrations/2019_08_19_000000_create_failed_jobs_table.php35
-rw-r--r--ssh/database/migrations/2020_03_19_145925_create_articles_table.php34
-rw-r--r--ssh/database/migrations/2020_03_19_150116_create_discussion_table.php44
-rw-r--r--ssh/database/migrations/2020_03_19_150930_create_category_table.php33
-rw-r--r--ssh/database/migrations/2020_03_19_154610_create_code_table.php40
-rw-r--r--ssh/database/migrations/2020_03_28_131201_create_view_popular_articles.php55
-rw-r--r--ssh/database/migrations/2020_03_28_132812_create_view_articles.php53
-rw-r--r--ssh/database/migrations/2020_03_28_164915_add_excerpt_to_article.php32
-rw-r--r--ssh/database/migrations/2020_03_28_194649_join_article_category_table.php37
11 files changed, 0 insertions, 431 deletions
diff --git a/ssh/database/migrations/2014_10_12_000000_create_users_table.php b/ssh/database/migrations/2014_10_12_000000_create_users_table.php
deleted file mode 100644
index 621a24e..0000000
--- a/ssh/database/migrations/2014_10_12_000000_create_users_table.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
-
-class CreateUsersTable extends Migration
-{
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- Schema::create('users', function (Blueprint $table) {
- $table->id();
- $table->string('name');
- $table->string('email')->unique();
- $table->timestamp('email_verified_at')->nullable();
- $table->string('password');
- $table->rememberToken();
- $table->timestamps();
- });
- }
-
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::dropIfExists('users');
- }
-}
diff --git a/ssh/database/migrations/2014_10_12_100000_create_password_resets_table.php b/ssh/database/migrations/2014_10_12_100000_create_password_resets_table.php
deleted file mode 100644
index 0ee0a36..0000000
--- a/ssh/database/migrations/2014_10_12_100000_create_password_resets_table.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
-
-class CreatePasswordResetsTable extends Migration
-{
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- Schema::create('password_resets', function (Blueprint $table) {
- $table->string('email')->index();
- $table->string('token');
- $table->timestamp('created_at')->nullable();
- });
- }
-
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::dropIfExists('password_resets');
- }
-}
diff --git a/ssh/database/migrations/2019_08_19_000000_create_failed_jobs_table.php b/ssh/database/migrations/2019_08_19_000000_create_failed_jobs_table.php
deleted file mode 100644
index 9bddee3..0000000
--- a/ssh/database/migrations/2019_08_19_000000_create_failed_jobs_table.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
-
-class CreateFailedJobsTable extends Migration
-{
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- Schema::create('failed_jobs', function (Blueprint $table) {
- $table->id();
- $table->text('connection');
- $table->text('queue');
- $table->longText('payload');
- $table->longText('exception');
- $table->timestamp('failed_at')->useCurrent();
- });
- }
-
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::dropIfExists('failed_jobs');
- }
-}
diff --git a/ssh/database/migrations/2020_03_19_145925_create_articles_table.php b/ssh/database/migrations/2020_03_19_145925_create_articles_table.php
deleted file mode 100644
index f7732ac..0000000
--- a/ssh/database/migrations/2020_03_19_145925_create_articles_table.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
-
-class CreateArticlesTable extends Migration
-{
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- Schema::create('article', function (Blueprint $table) {
- $table->id();
- $table->timestamps();
-
- $table->string('url')->unique();
- $table->string('title')->default('');
- });
- }
-
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::dropIfExists('article');
- }
-}
diff --git a/ssh/database/migrations/2020_03_19_150116_create_discussion_table.php b/ssh/database/migrations/2020_03_19_150116_create_discussion_table.php
deleted file mode 100644
index 1869892..0000000
--- a/ssh/database/migrations/2020_03_19_150116_create_discussion_table.php
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
-
-class CreateDiscussionTable extends Migration
-{
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- Schema::create('discussion', function (Blueprint $table) {
- $table->id();
- $table->timestamps();
-
- $table->unsignedBigInteger('article_id')->default(0);
- $table->string('title');
- $table->string('source');
- $table->string('item_id')->unique();
- $table->string('source_url');
- $table->integer('posted_on');
- $table->integer('comments')->default(0);
- $table->integer('upvotes')->default(0);
-
- $table->foreign('article_id')->references('id')->on('article')->onDelete('cascade');
-
- $table->unique(['item_id', 'posted_on', 'source']);
- });
- }
-
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::dropIfExists('discussion');
- }
-}
diff --git a/ssh/database/migrations/2020_03_19_150930_create_category_table.php b/ssh/database/migrations/2020_03_19_150930_create_category_table.php
deleted file mode 100644
index 20905b4..0000000
--- a/ssh/database/migrations/2020_03_19_150930_create_category_table.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
-
-class CreateCategoryTable extends Migration
-{
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- Schema::create('category', function (Blueprint $table) {
- $table->id();
- $table->timestamps();
-
- $table->string('name')->unique()->default('');
- });
- }
-
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::dropIfExists('category');
- }
-}
diff --git a/ssh/database/migrations/2020_03_19_154610_create_code_table.php b/ssh/database/migrations/2020_03_19_154610_create_code_table.php
deleted file mode 100644
index e8703dd..0000000
--- a/ssh/database/migrations/2020_03_19_154610_create_code_table.php
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
-
-class CreateCodeTable extends Migration
-{
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- Schema::create('code', function (Blueprint $table) {
- $table->id();
- $table->timestamps();
-
- $table->string('url');
- $table->string('title');
- $table->string('source');
- $table->string('item_id')->unique();
- $table->string('source_url');
- $table->integer('posted_on');
- $table->integer('comments')->default(0);
- $table->integer('upvotes')->default(0);
- });
- }
-
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::dropIfExists('code');
- }
-}
diff --git a/ssh/database/migrations/2020_03_28_131201_create_view_popular_articles.php b/ssh/database/migrations/2020_03_28_131201_create_view_popular_articles.php
deleted file mode 100644
index 062b8e0..0000000
--- a/ssh/database/migrations/2020_03_28_131201_create_view_popular_articles.php
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\DB;
-
-class CreateViewPopularArticles extends Migration
-{
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- DB::statement("
- CREATE VIEW view_popular AS
- SELECT
- article_id as id,
- article_id,
- a.created_at,
- a.updated_at,
- a.url,
- a.title,
- a.excerpt_html,
- sum(upvotes)+sum(comments) AS impact,
- sum(upvotes) AS upvotes,
- sum(comments) as comments,
- count(article_id) AS repost
- FROM
- discussion as d
- JOIN
- article AS a ON d.article_id = a.id
- GROUP BY
- article_id,
- a.created_at,
- a.updated_at,
- a.url,
- a.title,
- a.excerpt_html
- HAVING (impact > 300) OR (count(article_id) > 2)
- ORDER BY ((sum(upvotes)+sum(comments))*count(article_id)) desc, repost desc, impact desc"
- );
- }
-
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- DB::statement("DROP VIEW view_popular;");
- }
-}
diff --git a/ssh/database/migrations/2020_03_28_132812_create_view_articles.php b/ssh/database/migrations/2020_03_28_132812_create_view_articles.php
deleted file mode 100644
index 15fdee8..0000000
--- a/ssh/database/migrations/2020_03_28_132812_create_view_articles.php
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\DB;
-
-class CreateViewArticles extends Migration
-{
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- DB::statement(
- "CREATE VIEW view_article AS
- SELECT
- article_id as id,
- article_id,
- a.created_at,
- a.updated_at,
- a.url,
- a.title,
- a.excerpt_html,
- sum(upvotes)+sum(comments) AS impact,
- sum(upvotes) AS upvotes,
- sum(comments) as comments,
- count(article_id) AS repost
- FROM
- discussion as d
- JOIN
- article AS a ON d.article_id = a.id
- GROUP BY
- article_id,
- a.created_at,
- a.updated_at,
- a.url,
- a.title,
- a.excerpt_html"
- );
- }
-
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- DB::statement("DROP VIEW view_article;");
- }
-}
diff --git a/ssh/database/migrations/2020_03_28_164915_add_excerpt_to_article.php b/ssh/database/migrations/2020_03_28_164915_add_excerpt_to_article.php
deleted file mode 100644
index c4936b9..0000000
--- a/ssh/database/migrations/2020_03_28_164915_add_excerpt_to_article.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
-
-class AddExcerptToArticle extends Migration
-{
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- Schema::table('article', function (Blueprint $table) {
- $table->text('excerpt_html')->nullable();
- });
- }
-
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::table('article', function (Blueprint $table) {
- $table->dropColumn('excerpt_html');
- });
- }
-}
diff --git a/ssh/database/migrations/2020_03_28_194649_join_article_category_table.php b/ssh/database/migrations/2020_03_28_194649_join_article_category_table.php
deleted file mode 100644
index 3f843d4..0000000
--- a/ssh/database/migrations/2020_03_28_194649_join_article_category_table.php
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
-
-class JoinArticleCategoryTable extends Migration
-{
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- Schema::create('article_category', function (Blueprint $table) {
- $table->id();
- $table->unsignedBigInteger('article_id')->default(0);
- $table->unsignedBigInteger('category_id')->default(0);
-
- $table->foreign('article_id')->references('id')->on('article');
- $table->foreign('category_id')->references('id')->on('category');
-
- $table->unique(['article_id', 'category_id']);
- });
- }
-
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::dropIfExists('article_category');
- }
-}