From 046136faf9c5a262d3fbd48dd6039dd24d0c871f Mon Sep 17 00:00:00 2001 From: Alex Musayev Date: Sun, 28 Jul 2024 17:27:27 +0300 Subject: [PATCH] F2: Merge DB migrations (#550) * Merge migrations * Remove model reference from migration * Bump bundler version * Dump schema * Drop unused delayed jobs table --- Dockerfile | 2 +- db/migrate/20160912105557_create_feeds.rb | 13 +++ db/migrate/20160912110133_create_posts.rb | 17 +++ .../20160913121434_create_delayed_jobs.rb | 22 ++++ .../20160920171420_create_data_points.rb | 11 ++ ...20160920171429_create_data_point_series.rb | 10 ++ db/migrate/20160926170407_add_post_status.rb | 6 + .../20160926234238_update_post_statuses.rb | 13 +++ db/migrate/20160929123932_add_feed_details.rb | 7 ++ db/migrate/20170308200158_create_errors.rb | 17 +++ .../20180520150306_add_after_to_feeds.rb | 5 + ...0181029160355_add_refresh_time_to_feeds.rb | 5 + .../20181126110206_add_options_to_feeds.rb | 5 + .../20181126152746_add_loader_to_feeds.rb | 5 + ...0181126170638_add_import_limit_to_feeds.rb | 5 + db/migrate/20181126194822_add_uid_to_posts.rb | 10 ++ ...93619_add_last_post_created_at_to_feeds.rb | 5 + ...0624150553_add_feed_subscriptions_count.rb | 5 + .../20190701101346_create_blocked_ips.rb | 11 ++ db/migrate/20190726193542_add_feed_status.rb | 6 + .../20190817114629_add_target_to_errors.rb | 7 ++ .../20190819174940_default_occured_at.rb | 5 + ...22074055_add_validation_errors_to_posts.rb | 5 + .../20230604151916_create_nitter_instances.rb | 11 ++ .../20230607090837_add_state_to_feeds.rb | 5 + .../20230609145906_add_feed_error_counters.rb | 6 + ...0230613121056_change_feed_state_default.rb | 6 + ...615035946_add_disabling_reason_to_feeds.rb | 7 ++ .../20230616143631_create_sparklines.rb | 9 ++ db/migrate/20230629142633_drop_blocked_ips.rb | 13 +++ db/migrate/20230629170244_drop_data_points.rb | 19 ++++ .../20230630183347_add_state_to_posts.rb | 22 ++++ ...20230702113522_create_service_instances.rb | 16 +++ ...6_add_usages_count_to_service_instances.rb | 5 + ...0230818131852_change_posts_link_default.rb | 5 + ...20230818131932_add_posts_source_content.rb | 5 + .../20240728141124_drop_delayed_jobs.rb | 22 ++++ db/schema.rb | 106 +++++++++++++++++- 38 files changed, 452 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20160912105557_create_feeds.rb create mode 100644 db/migrate/20160912110133_create_posts.rb create mode 100644 db/migrate/20160913121434_create_delayed_jobs.rb create mode 100644 db/migrate/20160920171420_create_data_points.rb create mode 100644 db/migrate/20160920171429_create_data_point_series.rb create mode 100644 db/migrate/20160926170407_add_post_status.rb create mode 100644 db/migrate/20160926234238_update_post_statuses.rb create mode 100644 db/migrate/20160929123932_add_feed_details.rb create mode 100644 db/migrate/20170308200158_create_errors.rb create mode 100644 db/migrate/20180520150306_add_after_to_feeds.rb create mode 100644 db/migrate/20181029160355_add_refresh_time_to_feeds.rb create mode 100644 db/migrate/20181126110206_add_options_to_feeds.rb create mode 100644 db/migrate/20181126152746_add_loader_to_feeds.rb create mode 100644 db/migrate/20181126170638_add_import_limit_to_feeds.rb create mode 100644 db/migrate/20181126194822_add_uid_to_posts.rb create mode 100644 db/migrate/20190609193619_add_last_post_created_at_to_feeds.rb create mode 100644 db/migrate/20190624150553_add_feed_subscriptions_count.rb create mode 100644 db/migrate/20190701101346_create_blocked_ips.rb create mode 100644 db/migrate/20190726193542_add_feed_status.rb create mode 100644 db/migrate/20190817114629_add_target_to_errors.rb create mode 100644 db/migrate/20190819174940_default_occured_at.rb create mode 100644 db/migrate/20190822074055_add_validation_errors_to_posts.rb create mode 100644 db/migrate/20230604151916_create_nitter_instances.rb create mode 100644 db/migrate/20230607090837_add_state_to_feeds.rb create mode 100644 db/migrate/20230609145906_add_feed_error_counters.rb create mode 100644 db/migrate/20230613121056_change_feed_state_default.rb create mode 100644 db/migrate/20230615035946_add_disabling_reason_to_feeds.rb create mode 100644 db/migrate/20230616143631_create_sparklines.rb create mode 100644 db/migrate/20230629142633_drop_blocked_ips.rb create mode 100644 db/migrate/20230629170244_drop_data_points.rb create mode 100644 db/migrate/20230630183347_add_state_to_posts.rb create mode 100644 db/migrate/20230702113522_create_service_instances.rb create mode 100644 db/migrate/20230804133646_add_usages_count_to_service_instances.rb create mode 100644 db/migrate/20230818131852_change_posts_link_default.rb create mode 100644 db/migrate/20230818131932_add_posts_source_content.rb create mode 100644 db/migrate/20240728141124_drop_delayed_jobs.rb diff --git a/Dockerfile b/Dockerfile index 8af8d25f..4406ff8b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ RUN apt-get update --yes \ apt-utils \ build-essential \ vim \ - && gem install bundler:'~> 2.4' \ + && gem install bundler:'~> 2.5' \ && rm -rf /var/lib/apt/lists/* ARG RAILS_ENV diff --git a/db/migrate/20160912105557_create_feeds.rb b/db/migrate/20160912105557_create_feeds.rb new file mode 100644 index 00000000..ce38f09f --- /dev/null +++ b/db/migrate/20160912105557_create_feeds.rb @@ -0,0 +1,13 @@ +class CreateFeeds < ActiveRecord::Migration[5.0] + def change + create_table :feeds do |t| + t.string :name, null: false + t.integer :posts_count, null: false, default: 0 + t.datetime :refreshed_at + + t.timestamps + end + + add_index :feeds, :name, unique: true + end +end diff --git a/db/migrate/20160912110133_create_posts.rb b/db/migrate/20160912110133_create_posts.rb new file mode 100644 index 00000000..237f95ff --- /dev/null +++ b/db/migrate/20160912110133_create_posts.rb @@ -0,0 +1,17 @@ +class CreatePosts < ActiveRecord::Migration[5.0] + def change + create_table :posts do |t| + t.integer :feed_id, null: false + t.string :link, null: false + t.datetime :published_at, null: false + t.string :text, null: false, default: "" + t.string :attachments, null: false, array: true, default: [] + t.string :comments, null: false, array: true, default: [] + t.string :freefeed_post_id + t.timestamps + end + + add_index :posts, :feed_id + add_index :posts, :link + end +end diff --git a/db/migrate/20160913121434_create_delayed_jobs.rb b/db/migrate/20160913121434_create_delayed_jobs.rb new file mode 100644 index 00000000..818dce5b --- /dev/null +++ b/db/migrate/20160913121434_create_delayed_jobs.rb @@ -0,0 +1,22 @@ +class CreateDelayedJobs < ActiveRecord::Migration[4.2] + def self.up + create_table :delayed_jobs, force: true do |table| + table.integer :priority, default: 0, null: false # Allows some jobs to jump to the front of the queue + table.integer :attempts, default: 0, null: false # Provides for retries, but still fail eventually. + table.text :handler, null: false # YAML-encoded string of the object that will do work + table.text :last_error # reason for last failure (See Note below) + table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future. + table.datetime :locked_at # Set when a client is working on this object + table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead) + table.string :locked_by # Who is working on this object (if locked) + table.string :queue # The name of the queue this job is in + table.timestamps null: true + end + + add_index :delayed_jobs, [:priority, :run_at], name: "delayed_jobs_priority" + end + + def self.down + drop_table :delayed_jobs + end +end diff --git a/db/migrate/20160920171420_create_data_points.rb b/db/migrate/20160920171420_create_data_points.rb new file mode 100644 index 00000000..3fcbd708 --- /dev/null +++ b/db/migrate/20160920171420_create_data_points.rb @@ -0,0 +1,11 @@ +class CreateDataPoints < ActiveRecord::Migration[5.0] + def change + create_table :data_points do |t| + t.integer :series_id + t.json :details, null: false, default: {} + t.datetime :created_at, null: false + end + + add_index :data_points, :series_id + end +end diff --git a/db/migrate/20160920171429_create_data_point_series.rb b/db/migrate/20160920171429_create_data_point_series.rb new file mode 100644 index 00000000..862e6c11 --- /dev/null +++ b/db/migrate/20160920171429_create_data_point_series.rb @@ -0,0 +1,10 @@ +class CreateDataPointSeries < ActiveRecord::Migration[5.0] + def change + create_table :data_point_series do |t| + t.string :name, null: false + t.datetime :created_at, null: false + end + + add_index :data_point_series, :name, unique: true + end +end diff --git a/db/migrate/20160926170407_add_post_status.rb b/db/migrate/20160926170407_add_post_status.rb new file mode 100644 index 00000000..b9aab576 --- /dev/null +++ b/db/migrate/20160926170407_add_post_status.rb @@ -0,0 +1,6 @@ +class AddPostStatus < ActiveRecord::Migration[5.0] + def change + add_column :posts, :status, :integer, null: false, default: 0 + add_index :posts, :status + end +end diff --git a/db/migrate/20160926234238_update_post_statuses.rb b/db/migrate/20160926234238_update_post_statuses.rb new file mode 100644 index 00000000..dcce85e6 --- /dev/null +++ b/db/migrate/20160926234238_update_post_statuses.rb @@ -0,0 +1,13 @@ +class UpdatePostStatuses < ActiveRecord::Migration[5.0] + def up + # Replace "idle" status with "published" + execute <<-SQL + UPDATE posts + SET status = 2 + WHERE status = 0 AND freefeed_post_id IS NOT NULL + SQL + end + + def down + end +end diff --git a/db/migrate/20160929123932_add_feed_details.rb b/db/migrate/20160929123932_add_feed_details.rb new file mode 100644 index 00000000..600316bc --- /dev/null +++ b/db/migrate/20160929123932_add_feed_details.rb @@ -0,0 +1,7 @@ +class AddFeedDetails < ActiveRecord::Migration[5.0] + def change + add_column :feeds, :url, :string + add_column :feeds, :processor, :string + add_column :feeds, :normalizer, :string + end +end diff --git a/db/migrate/20170308200158_create_errors.rb b/db/migrate/20170308200158_create_errors.rb new file mode 100644 index 00000000..509881f4 --- /dev/null +++ b/db/migrate/20170308200158_create_errors.rb @@ -0,0 +1,17 @@ +class CreateErrors < ActiveRecord::Migration[5.0] + def change + create_table "errors" do |t| + t.integer "status", default: 0, null: false, index: true + t.string "error_class_name", default: "", null: false, index: true + t.string "file_name", index: true + t.integer "line_number" + t.string "label", default: "", null: false + t.string "message", default: "", null: false + t.string "backtrace", default: [], null: false, array: true + t.string "filtered_backtrace", default: [], null: false, array: true + t.json "context", default: {}, null: false + t.datetime "occured_at", null: false, index: true + t.timestamps + end + end +end diff --git a/db/migrate/20180520150306_add_after_to_feeds.rb b/db/migrate/20180520150306_add_after_to_feeds.rb new file mode 100644 index 00000000..c4554de0 --- /dev/null +++ b/db/migrate/20180520150306_add_after_to_feeds.rb @@ -0,0 +1,5 @@ +class AddAfterToFeeds < ActiveRecord::Migration[5.1] + def change + add_column :feeds, :after, :datetime + end +end diff --git a/db/migrate/20181029160355_add_refresh_time_to_feeds.rb b/db/migrate/20181029160355_add_refresh_time_to_feeds.rb new file mode 100644 index 00000000..648cb250 --- /dev/null +++ b/db/migrate/20181029160355_add_refresh_time_to_feeds.rb @@ -0,0 +1,5 @@ +class AddRefreshTimeToFeeds < ActiveRecord::Migration[5.2] + def change + add_column :feeds, :refresh_interval, :integer, null: false, default: 0 + end +end diff --git a/db/migrate/20181126110206_add_options_to_feeds.rb b/db/migrate/20181126110206_add_options_to_feeds.rb new file mode 100644 index 00000000..208c3027 --- /dev/null +++ b/db/migrate/20181126110206_add_options_to_feeds.rb @@ -0,0 +1,5 @@ +class AddOptionsToFeeds < ActiveRecord::Migration[5.2] + def change + add_column :feeds, :options, :json, null: false, default: {} + end +end diff --git a/db/migrate/20181126152746_add_loader_to_feeds.rb b/db/migrate/20181126152746_add_loader_to_feeds.rb new file mode 100644 index 00000000..06658852 --- /dev/null +++ b/db/migrate/20181126152746_add_loader_to_feeds.rb @@ -0,0 +1,5 @@ +class AddLoaderToFeeds < ActiveRecord::Migration[5.2] + def change + add_column :feeds, :loader, :string + end +end diff --git a/db/migrate/20181126170638_add_import_limit_to_feeds.rb b/db/migrate/20181126170638_add_import_limit_to_feeds.rb new file mode 100644 index 00000000..36535807 --- /dev/null +++ b/db/migrate/20181126170638_add_import_limit_to_feeds.rb @@ -0,0 +1,5 @@ +class AddImportLimitToFeeds < ActiveRecord::Migration[5.2] + def change + add_column :feeds, :import_limit, :integer + end +end diff --git a/db/migrate/20181126194822_add_uid_to_posts.rb b/db/migrate/20181126194822_add_uid_to_posts.rb new file mode 100644 index 00000000..7e087deb --- /dev/null +++ b/db/migrate/20181126194822_add_uid_to_posts.rb @@ -0,0 +1,10 @@ +class AddUidToPosts < ActiveRecord::Migration[5.2] + class Post < ActiveRecord::Base + end + + def change + add_column :posts, :uid, :string + Post.update_all("uid = link") + change_column :posts, :uid, :string, null: false + end +end diff --git a/db/migrate/20190609193619_add_last_post_created_at_to_feeds.rb b/db/migrate/20190609193619_add_last_post_created_at_to_feeds.rb new file mode 100644 index 00000000..899d26bc --- /dev/null +++ b/db/migrate/20190609193619_add_last_post_created_at_to_feeds.rb @@ -0,0 +1,5 @@ +class AddLastPostCreatedAtToFeeds < ActiveRecord::Migration[5.2] + def change + add_column :feeds, :last_post_created_at, :datetime + end +end diff --git a/db/migrate/20190624150553_add_feed_subscriptions_count.rb b/db/migrate/20190624150553_add_feed_subscriptions_count.rb new file mode 100644 index 00000000..9ac27df1 --- /dev/null +++ b/db/migrate/20190624150553_add_feed_subscriptions_count.rb @@ -0,0 +1,5 @@ +class AddFeedSubscriptionsCount < ActiveRecord::Migration[5.2] + def change + add_column :feeds, :subscriptions_count, :integer, null: false, default: 0 + end +end diff --git a/db/migrate/20190701101346_create_blocked_ips.rb b/db/migrate/20190701101346_create_blocked_ips.rb new file mode 100644 index 00000000..582eb476 --- /dev/null +++ b/db/migrate/20190701101346_create_blocked_ips.rb @@ -0,0 +1,11 @@ +class CreateBlockedIps < ActiveRecord::Migration[5.2] + def change + create_table :blocked_ips do |t| + t.inet :ip, null: false + t.datetime :created_at, default: -> { "CURRENT_TIMESTAMP" } + t.datetime :updated_at, default: -> { "CURRENT_TIMESTAMP" } + end + + add_index :blocked_ips, :ip, unique: true + end +end diff --git a/db/migrate/20190726193542_add_feed_status.rb b/db/migrate/20190726193542_add_feed_status.rb new file mode 100644 index 00000000..3b4b6fe4 --- /dev/null +++ b/db/migrate/20190726193542_add_feed_status.rb @@ -0,0 +1,6 @@ +class AddFeedStatus < ActiveRecord::Migration[5.2] + def change + add_column :feeds, :status, :integer, null: false, default: 0 + add_index :feeds, :status + end +end diff --git a/db/migrate/20190817114629_add_target_to_errors.rb b/db/migrate/20190817114629_add_target_to_errors.rb new file mode 100644 index 00000000..599303dd --- /dev/null +++ b/db/migrate/20190817114629_add_target_to_errors.rb @@ -0,0 +1,7 @@ +class AddTargetToErrors < ActiveRecord::Migration[5.2] + def change + add_reference :errors, :target, polymorphic: true + remove_column :errors, :filtered_backtrace, :string, default: [], null: false, array: true + rename_column :errors, :error_class_name, :exception + end +end diff --git a/db/migrate/20190819174940_default_occured_at.rb b/db/migrate/20190819174940_default_occured_at.rb new file mode 100644 index 00000000..fb2425e9 --- /dev/null +++ b/db/migrate/20190819174940_default_occured_at.rb @@ -0,0 +1,5 @@ +class DefaultOccuredAt < ActiveRecord::Migration[6.0] + def change + change_column :errors, :occured_at, :datetime, default: -> { "CURRENT_TIMESTAMP" } + end +end diff --git a/db/migrate/20190822074055_add_validation_errors_to_posts.rb b/db/migrate/20190822074055_add_validation_errors_to_posts.rb new file mode 100644 index 00000000..7e59c970 --- /dev/null +++ b/db/migrate/20190822074055_add_validation_errors_to_posts.rb @@ -0,0 +1,5 @@ +class AddValidationErrorsToPosts < ActiveRecord::Migration[6.0] + def change + add_column :posts, :validation_errors, :string, array: true, default: [], null: false + end +end diff --git a/db/migrate/20230604151916_create_nitter_instances.rb b/db/migrate/20230604151916_create_nitter_instances.rb new file mode 100644 index 00000000..c4ad136e --- /dev/null +++ b/db/migrate/20230604151916_create_nitter_instances.rb @@ -0,0 +1,11 @@ +class CreateNitterInstances < ActiveRecord::Migration[6.1] + def change + create_table :nitter_instances do |t| + t.string :status, null: false, index: true + t.string :url, null: false, index: true + t.datetime :errored_at, index: true + t.integer :errors_count, null: false, default: 0 + t.timestamps + end + end +end diff --git a/db/migrate/20230607090837_add_state_to_feeds.rb b/db/migrate/20230607090837_add_state_to_feeds.rb new file mode 100644 index 00000000..640ac1f9 --- /dev/null +++ b/db/migrate/20230607090837_add_state_to_feeds.rb @@ -0,0 +1,5 @@ +class AddStateToFeeds < ActiveRecord::Migration[6.1] + def change + add_column :feeds, :state, :string, null: false, default: "enabled" + end +end diff --git a/db/migrate/20230609145906_add_feed_error_counters.rb b/db/migrate/20230609145906_add_feed_error_counters.rb new file mode 100644 index 00000000..db67812e --- /dev/null +++ b/db/migrate/20230609145906_add_feed_error_counters.rb @@ -0,0 +1,6 @@ +class AddFeedErrorCounters < ActiveRecord::Migration[6.1] + def change + add_column :feeds, :errors_count, :integer, null: false, default: 0 + add_column :feeds, :total_errors_count, :integer, null: false, default: 0 + end +end diff --git a/db/migrate/20230613121056_change_feed_state_default.rb b/db/migrate/20230613121056_change_feed_state_default.rb new file mode 100644 index 00000000..3cf030b4 --- /dev/null +++ b/db/migrate/20230613121056_change_feed_state_default.rb @@ -0,0 +1,6 @@ +class ChangeFeedStateDefault < ActiveRecord::Migration[6.1] + def change + add_column :feeds, :state_updated_at, :datetime + change_column_default :feeds, :state, from: "enabled", to: "pristine" + end +end diff --git a/db/migrate/20230615035946_add_disabling_reason_to_feeds.rb b/db/migrate/20230615035946_add_disabling_reason_to_feeds.rb new file mode 100644 index 00000000..571360aa --- /dev/null +++ b/db/migrate/20230615035946_add_disabling_reason_to_feeds.rb @@ -0,0 +1,7 @@ +class AddDisablingReasonToFeeds < ActiveRecord::Migration[6.1] + def change + add_column :feeds, :source, :string, null: false, default: "" + add_column :feeds, :description, :string, null: false, default: "" + add_column :feeds, :disabling_reason, :string, null: false, default: "" + end +end diff --git a/db/migrate/20230616143631_create_sparklines.rb b/db/migrate/20230616143631_create_sparklines.rb new file mode 100644 index 00000000..484592bd --- /dev/null +++ b/db/migrate/20230616143631_create_sparklines.rb @@ -0,0 +1,9 @@ +class CreateSparklines < ActiveRecord::Migration[6.1] + def change + create_table :sparklines do |t| + t.belongs_to :feed, index: true + t.jsonb :data, null: false, default: {} + t.timestamps + end + end +end diff --git a/db/migrate/20230629142633_drop_blocked_ips.rb b/db/migrate/20230629142633_drop_blocked_ips.rb new file mode 100644 index 00000000..890f454a --- /dev/null +++ b/db/migrate/20230629142633_drop_blocked_ips.rb @@ -0,0 +1,13 @@ +class DropBlockedIps < ActiveRecord::Migration[6.1] + def self.up + drop_table :blocked_ips + end + + def self.down + create_table :blocked_ips do |t| + t.inet :ip, null: false + t.datetime :created_at, default: -> { "CURRENT_TIMESTAMP" } + t.datetime :updated_at, default: -> { "CURRENT_TIMESTAMP" } + end + end +end diff --git a/db/migrate/20230629170244_drop_data_points.rb b/db/migrate/20230629170244_drop_data_points.rb new file mode 100644 index 00000000..d2e300b5 --- /dev/null +++ b/db/migrate/20230629170244_drop_data_points.rb @@ -0,0 +1,19 @@ +class DropDataPoints < ActiveRecord::Migration[6.1] + def self.up + drop_table :data_points + drop_table :data_point_series + end + + def self.down + create_table :data_points do |t| + t.integer :series_id, index: true + t.json :details, null: false, default: {} + t.datetime :created_at, null: false + end + + create_table :data_point_series do |t| + t.string :name, null: false, index: true + t.datetime :created_at, null: false + end + end +end diff --git a/db/migrate/20230630183347_add_state_to_posts.rb b/db/migrate/20230630183347_add_state_to_posts.rb new file mode 100644 index 00000000..61fa9e81 --- /dev/null +++ b/db/migrate/20230630183347_add_state_to_posts.rb @@ -0,0 +1,22 @@ +# State backfill: +# +# Status values: +# - idle: 0 +# - ready: 1 +# - published: 2 +# - ignored: 3 +# - not_valid: 4 +# - error: 5 +# +# scope = Post.where("created_at <= ?", DateTime.parse("Sat, 01 Jul 2023 14:15:16.356921000 UTC +00:00")); nil +# scope.where(status: 0).update_all(state: "rejected") +# scope.where(status: 2).update_all(state: "published") +# scope.where(status: 3).update_all(state: "rejected") +# scope.where(status: 4).update_all(state: "rejected") +# scope.where(status: 5).update_all(state: "failed") +# +class AddStateToPosts < ActiveRecord::Migration[6.1] + def change + add_column :posts, :state, :string, null: false, default: "draft" + end +end diff --git a/db/migrate/20230702113522_create_service_instances.rb b/db/migrate/20230702113522_create_service_instances.rb new file mode 100644 index 00000000..b439e02b --- /dev/null +++ b/db/migrate/20230702113522_create_service_instances.rb @@ -0,0 +1,16 @@ +class CreateServiceInstances < ActiveRecord::Migration[6.1] + def change + create_table :service_instances do |t| + t.string :service_type, null: false + t.string :state, null: false, index: true + t.string :url, null: false + t.integer :errors_count, null: false, default: 0 + t.integer :total_errors_count, null: false, default: 0 + t.datetime :used_at + t.datetime :failed_at + t.timestamps + end + + add_index :service_instances, [:service_type, :url], unique: true + end +end diff --git a/db/migrate/20230804133646_add_usages_count_to_service_instances.rb b/db/migrate/20230804133646_add_usages_count_to_service_instances.rb new file mode 100644 index 00000000..1566dc0e --- /dev/null +++ b/db/migrate/20230804133646_add_usages_count_to_service_instances.rb @@ -0,0 +1,5 @@ +class AddUsagesCountToServiceInstances < ActiveRecord::Migration[7.0] + def change + add_column :service_instances, :usages_count, :integer, null: false, default: 0 + end +end diff --git a/db/migrate/20230818131852_change_posts_link_default.rb b/db/migrate/20230818131852_change_posts_link_default.rb new file mode 100644 index 00000000..025f20fd --- /dev/null +++ b/db/migrate/20230818131852_change_posts_link_default.rb @@ -0,0 +1,5 @@ +class ChangePostsLinkDefault < ActiveRecord::Migration[7.0] + def change + change_column_default :posts, :link, from: nil, to: "" + end +end diff --git a/db/migrate/20230818131932_add_posts_source_content.rb b/db/migrate/20230818131932_add_posts_source_content.rb new file mode 100644 index 00000000..cd24060a --- /dev/null +++ b/db/migrate/20230818131932_add_posts_source_content.rb @@ -0,0 +1,5 @@ +class AddPostsSourceContent < ActiveRecord::Migration[7.0] + def change + add_column :posts, :source_content, :jsonb, null: false, default: {} + end +end diff --git a/db/migrate/20240728141124_drop_delayed_jobs.rb b/db/migrate/20240728141124_drop_delayed_jobs.rb new file mode 100644 index 00000000..8b369a31 --- /dev/null +++ b/db/migrate/20240728141124_drop_delayed_jobs.rb @@ -0,0 +1,22 @@ +class DropDelayedJobs < ActiveRecord::Migration[7.1] + def up + drop_table :delayed_jobs, if_exists: true + end + + def down + create_table :delayed_jobs, if_not_exists: true, force: true do |table| + table.integer :priority, default: 0, null: false + table.integer :attempts, default: 0, null: false + table.text :handler, null: false + table.text :last_error + table.datetime :run_at + table.datetime :locked_at + table.datetime :failed_at + table.string :locked_by + table.string :queue + table.timestamps null: true + end + + add_index :delayed_jobs, [:priority, :run_at], name: "delayed_jobs_priority" + end +end diff --git a/db/schema.rb b/db/schema.rb index f9139984..34cf1ff1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,8 +10,112 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 0) do +ActiveRecord::Schema[7.1].define(version: 2024_07_28_141124) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" + create_table "errors", id: :serial, force: :cascade do |t| + t.integer "status", default: 0, null: false + t.string "exception", default: "", null: false + t.string "file_name" + t.integer "line_number" + t.string "label", default: "", null: false + t.string "message", default: "", null: false + t.string "backtrace", default: [], null: false, array: true + t.json "context", default: {}, null: false + t.datetime "occured_at", precision: nil, default: -> { "CURRENT_TIMESTAMP" }, null: false + t.datetime "created_at", precision: nil, null: false + t.datetime "updated_at", precision: nil, null: false + t.string "target_type" + t.bigint "target_id" + t.index ["exception"], name: "index_errors_on_exception" + t.index ["file_name"], name: "index_errors_on_file_name" + t.index ["occured_at"], name: "index_errors_on_occured_at" + t.index ["status"], name: "index_errors_on_status" + t.index ["target_type", "target_id"], name: "index_errors_on_target_type_and_target_id" + end + + create_table "feeds", id: :serial, force: :cascade do |t| + t.string "name", null: false + t.integer "posts_count", default: 0, null: false + t.datetime "refreshed_at", precision: nil + t.datetime "created_at", precision: nil, null: false + t.datetime "updated_at", precision: nil, null: false + t.string "url" + t.string "processor" + t.string "normalizer" + t.datetime "after", precision: nil + t.integer "refresh_interval", default: 0, null: false + t.json "options", default: {}, null: false + t.string "loader" + t.integer "import_limit" + t.datetime "last_post_created_at", precision: nil + t.integer "subscriptions_count", default: 0, null: false + t.integer "status", default: 0, null: false + t.string "state", default: "pristine", null: false + t.integer "errors_count", default: 0, null: false + t.integer "total_errors_count", default: 0, null: false + t.datetime "state_updated_at", precision: nil + t.string "source", default: "", null: false + t.string "description", default: "", null: false + t.string "disabling_reason", default: "", null: false + t.index ["name"], name: "index_feeds_on_name", unique: true + t.index ["status"], name: "index_feeds_on_status" + end + + create_table "nitter_instances", force: :cascade do |t| + t.string "status", null: false + t.string "url", null: false + t.datetime "errored_at", precision: nil + t.integer "errors_count", default: 0, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["errored_at"], name: "index_nitter_instances_on_errored_at" + t.index ["status"], name: "index_nitter_instances_on_status" + t.index ["url"], name: "index_nitter_instances_on_url" + end + + create_table "posts", id: :serial, force: :cascade do |t| + t.integer "feed_id", null: false + t.string "link", default: "", null: false + t.datetime "published_at", precision: nil, null: false + t.string "text", default: "", null: false + t.string "attachments", default: [], null: false, array: true + t.string "comments", default: [], null: false, array: true + t.string "freefeed_post_id" + t.datetime "created_at", precision: nil, null: false + t.datetime "updated_at", precision: nil, null: false + t.integer "status", default: 0, null: false + t.string "uid", null: false + t.string "validation_errors", default: [], null: false, array: true + t.string "state", default: "draft", null: false + t.jsonb "source_content", default: {}, null: false + t.index ["feed_id"], name: "index_posts_on_feed_id" + t.index ["link"], name: "index_posts_on_link" + t.index ["status"], name: "index_posts_on_status" + end + + create_table "service_instances", force: :cascade do |t| + t.string "service_type", null: false + t.string "state", null: false + t.string "url", null: false + t.integer "errors_count", default: 0, null: false + t.integer "total_errors_count", default: 0, null: false + t.datetime "used_at", precision: nil + t.datetime "failed_at", precision: nil + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "usages_count", default: 0, null: false + t.index ["service_type", "url"], name: "index_service_instances_on_service_type_and_url", unique: true + t.index ["state"], name: "index_service_instances_on_state" + end + + create_table "sparklines", force: :cascade do |t| + t.bigint "feed_id" + t.jsonb "data", default: {}, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["feed_id"], name: "index_sparklines_on_feed_id" + end + end