Fix lints in database/migration code

This commit is contained in:
Andreas Nedbal 2023-10-20 01:37:34 +02:00 committed by Andreas Nedbal
parent 16071d6a86
commit 72af3c4d0b
66 changed files with 187 additions and 64 deletions

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class DeviseCreateUsers < ActiveRecord::Migration[4.2]
def change
create_table(:users) do |t|
@ -30,7 +32,6 @@ class DeviseCreateUsers < ActiveRecord::Migration[4.2]
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at
t.timestamps
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddScreenNameToUsers < ActiveRecord::Migration[4.2]
def change
add_column :users, :screen_name, :string

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CreateQuestions < ActiveRecord::Migration[4.2]
def change
create_table :questions do |t|
@ -9,6 +11,6 @@ class CreateQuestions < ActiveRecord::Migration[4.2]
t.timestamps
end
add_index :questions, [:user_id, :created_at]
add_index :questions, %i[user_id created_at]
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CreateAnswers < ActiveRecord::Migration[4.2]
def change
create_table :answers do |t|
@ -9,6 +11,6 @@ class CreateAnswers < ActiveRecord::Migration[4.2]
t.timestamps
end
add_index :answers, [:user_id, :created_at]
add_index :answers, %i[user_id created_at]
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CreateComments < ActiveRecord::Migration[4.2]
def change
create_table :comments do |t|
@ -7,6 +9,6 @@ class CreateComments < ActiveRecord::Migration[4.2]
t.timestamps
end
add_index :comments, [:user_id, :created_at]
add_index :comments, %i[user_id created_at]
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddCountsToUsers < ActiveRecord::Migration[4.2]
def change
add_column :users, :friend_count, :integer, default: 0, null: false

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddDisplayNameToUsers < ActiveRecord::Migration[4.2]
def change
add_column :users, :display_name, :string

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CreateInboxes < ActiveRecord::Migration[4.2]
def change
create_table :inboxes do |t|

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddSmileCountToAnswers < ActiveRecord::Migration[4.2]
def change
add_column :answers, :smile_count, :integer, default: 0, null: false

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddSmiledCountToUsers < ActiveRecord::Migration[4.2]
def change
add_column :users, :smiled_count, :integer, default: 0, null: false

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddAdminToUsers < ActiveRecord::Migration[4.2]
def change
add_column :users, :admin, :boolean, default: false, null: false

View file

@ -1,5 +1,7 @@
# frozen_string_literal: true
class AddMotivationHeaderToUsers < ActiveRecord::Migration[4.2]
def change
add_column :users, :motivation_header, :string, default: '', null: false
add_column :users, :motivation_header, :string, default: "", null: false
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CreateRelationships < ActiveRecord::Migration[4.2]
def change
create_table :relationships do |t|
@ -9,6 +11,6 @@ class CreateRelationships < ActiveRecord::Migration[4.2]
add_index :relationships, :source_id
add_index :relationships, :target_id
add_index :relationships, [:source_id, :target_id], unique: true
add_index :relationships, %i[source_id target_id], unique: true
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CreateSmiles < ActiveRecord::Migration[4.2]
def change
create_table :smiles do |t|
@ -9,6 +11,6 @@ class CreateSmiles < ActiveRecord::Migration[4.2]
add_index :smiles, :user_id
add_index :smiles, :answer_id
add_index :smiles, [:user_id, :answer_id], unique: true
add_index :smiles, %i[user_id answer_id], unique: true
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class RenameColumnsInAnswers < ActiveRecord::Migration[4.2]
def change
rename_column :answers, :comments, :comment_count

View file

@ -1,7 +1,9 @@
# frozen_string_literal: true
class AddFieldsToUsers < ActiveRecord::Migration[4.2]
def change
add_column :users, :website, :string, default: '', null: false
add_column :users, :location, :string, default: '', null: false
add_column :users, :bio, :text, default: '', null: false
add_column :users, :website, :string, default: "", null: false
add_column :users, :location, :string, default: "", null: false
add_column :users, :bio, :text, default: "", null: false
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddAnswerCountToQuestions < ActiveRecord::Migration[4.2]
def change
add_column :questions, :answer_count, :integer, default: 0, null: false

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ChangeAnswerContentColumnType < ActiveRecord::Migration[4.2]
def change
change_table :answers do |t|

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CreateServices < ActiveRecord::Migration[4.2]
def change
create_table :services do |t|

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CreateNotifications < ActiveRecord::Migration[4.2]
def change
create_table :notifications do |t|

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddModeratorToUsers < ActiveRecord::Migration[4.2]
def change
add_column :users, :moderator, :boolean, default: false, null: false

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CreateReports < ActiveRecord::Migration[4.2]
def change
create_table :reports do |t|

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CreateModerationVotes < ActiveRecord::Migration[4.2]
def change
create_table :moderation_votes do |t|
@ -10,6 +12,6 @@ class CreateModerationVotes < ActiveRecord::Migration[4.2]
add_index :moderation_votes, :user_id
add_index :moderation_votes, :report_id
add_index :moderation_votes, [:user_id, :report_id], unique: true
add_index :moderation_votes, %i[user_id report_id], unique: true
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CreateModerationComments < ActiveRecord::Migration[4.2]
def change
create_table :moderation_comments do |t|
@ -8,6 +10,6 @@ class CreateModerationComments < ActiveRecord::Migration[4.2]
t.timestamps
end
add_index :moderation_comments, [:user_id, :created_at]
add_index :moderation_comments, %i[user_id created_at]
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddDeletedToReports < ActiveRecord::Migration[4.2]
def change
add_column :reports, :deleted, :boolean, default: false

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddAttachmentProfilePictureToUsers < ActiveRecord::Migration[4.2]
def self.up
change_table :users do |t|

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddProfilePictureProcessingToUsers < ActiveRecord::Migration[4.2]
def change
add_column :users, :profile_picture_processing, :boolean

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddCropValuesToUsers < ActiveRecord::Migration[4.2]
def change
# this is a ugly hack and will stay until I find a way to pass parameters

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddSupporterToUsers < ActiveRecord::Migration[4.2]
def change
add_column :users, :supporter, :boolean, default: false

View file

@ -1,11 +1,13 @@
# frozen_string_literal: true
class AddPrivacyOptionsToUsers < ActiveRecord::Migration[4.2]
def change
%i{
%i[
privacy_allow_anonymous_questions
privacy_allow_public_timeline
privacy_allow_stranger_answers
privacy_show_in_search
}.each do |sym|
].each do |sym|
add_column :users, sym, :boolean, default: true
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddBannedToUsers < ActiveRecord::Migration[4.2]
def change
add_column :users, :banned, :boolean, default: false

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CreateGroups < ActiveRecord::Migration[4.2]
def change
create_table :groups do |t|
@ -11,7 +13,7 @@ class CreateGroups < ActiveRecord::Migration[4.2]
add_index :groups, :user_id
add_index :groups, :name
add_index :groups, [:user_id, :name], unique: true
add_index :groups, %i[user_id name], unique: true
create_table :group_members do |t|
t.integer :group_id, null: false
@ -22,6 +24,6 @@ class CreateGroups < ActiveRecord::Migration[4.2]
add_index :group_members, :group_id
add_index :group_members, :user_id
add_index :group_members, [:group_id, :user_id], unique: true
add_index :group_members, %i[group_id user_id], unique: true
end
end

View file

@ -1,5 +1,7 @@
# frozen_string_literal: true
class AddBloggerToUsers < ActiveRecord::Migration[4.2]
def change
add_column :users, :blogger, :boolean, default: :false
add_column :users, :blogger, :boolean, default: false
end
end

View file

@ -1,5 +1,7 @@
# frozen_string_literal: true
class AddContributorToUsers < ActiveRecord::Migration[4.2]
def change
add_column :users, :contributor, :boolean, default: :false
add_column :users, :contributor, :boolean, default: false
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CreateSubscriptions < ActiveRecord::Migration[4.2]
def change
create_table :subscriptions do |t|

View file

@ -1,5 +1,7 @@
# frozen_string_literal: true
class AddIsActiveToSubscriptions < ActiveRecord::Migration[4.2]
def change
add_column :subscriptions, :is_active, :boolean, default: :true
add_column :subscriptions, :is_active, :boolean, default: true
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddReasonToReport < ActiveRecord::Migration[4.2]
def change
add_column :reports, :reason, :string, default: nil

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class RenameBannedToPermanentlyBannedInUsers < ActiveRecord::Migration[4.2]
def up
rename_column :users, :banned, :permanently_banned

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddBanReasonAndBannedUntilToUsers < ActiveRecord::Migration[4.2]
def change
add_column :users, :ban_reason, :string, default: nil

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CreateCommentSmiles < ActiveRecord::Migration[4.2]
def change
create_table :comment_smiles do |t|
@ -9,7 +11,7 @@ class CreateCommentSmiles < ActiveRecord::Migration[4.2]
add_index :comment_smiles, :user_id
add_index :comment_smiles, :comment_id
add_index :comment_smiles, [:user_id, :comment_id], unique: true
add_index :comment_smiles, %i[user_id comment_id], unique: true
add_column :users, :comment_smiled_count, :integer, default: 0, null: false
add_column :comments, :smile_count, :integer, default: 0, null: false

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddAttachmentProfileHeaderToUsers < ActiveRecord::Migration[4.2]
def change
change_table :users do |t|

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddLocaleToUser < ActiveRecord::Migration[4.2]
def change
add_column :users, :locale, :string

View file

@ -1,5 +1,7 @@
# frozen_string_literal: true
class AddTranslatorToUsers < ActiveRecord::Migration[4.2]
def change
add_column :users, :translator, :boolean, default: :false
add_column :users, :translator, :boolean, default: false
end
end

View file

@ -1,5 +1,7 @@
# frozen_string_literal: true
class ChangeDefaultValueOfLocale < ActiveRecord::Migration[4.2]
def change
change_column :users, :locale, :string, :default => 'en'
change_column :users, :locale, :string, default: "en"
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddConfirmableToDevise < ActiveRecord::Migration[4.2]
def up
add_column :users, :confirmation_token, :string

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CreateThemes < ActiveRecord::Migration[4.2]
def change
create_table :themes do |t|
@ -38,6 +40,6 @@ class CreateThemes < ActiveRecord::Migration[4.2]
t.timestamps null: false
end
add_index :themes, [:user_id, :created_at]
add_index :themes, %i[user_id created_at]
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddShowForeignThemesToUsers < ActiveRecord::Migration[4.2]
def change
add_column :users, :show_foreign_themes, :boolean, default: true, null: false

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddInputAndOutlineToTheme < ActiveRecord::Migration[4.2]
def change
add_column :themes, :input_color, :integer, default: 0xFFFFFF, null: false

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddExportFieldsToUsers < ActiveRecord::Migration[4.2]
def change
add_column :users, :export_url, :string

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CreateAnnouncements < ActiveRecord::Migration[5.2]
def change
create_table :announcements do |t|

View file

@ -7,11 +7,11 @@ class CreateInitialRoles < ActiveRecord::Migration[5.2]
end
{
admin: :administrator,
moderator: :moderator
admin: :administrator,
moderator: :moderator,
}.each do |legacy_role, new_role|
User.where(legacy_role => true).each do |u|
puts "-- migrating #{u.screen_name} (#{u.id}) from field:#{legacy_role} to role:#{new_role}"
User.where(legacy_role => true).find_each do |u|
Rails.logger.debug { "-- migrating #{u.screen_name} (#{u.id}) from field:#{legacy_role} to role:#{new_role}" }
u.add_role new_role
u.public_send("#{legacy_role}=", false)
u.save!
@ -22,10 +22,10 @@ class CreateInitialRoles < ActiveRecord::Migration[5.2]
def down
{
administrator: :admin,
moderator: :moderator
moderator: :moderator,
}.each do |new_role, legacy_role|
User.with_role(new_role).each do |u|
puts "-- migrating #{u.screen_name} (#{u.id}) from role:#{new_role} to field:#{legacy_role}"
Rails.logger.debug { "-- migrating #{u.screen_name} (#{u.id}) from role:#{new_role} to field:#{legacy_role}" }
u.public_send("#{legacy_role}=", true)
u.save!
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class RemoveUnusedProfileFlags < ActiveRecord::Migration[5.2]
def change
remove_column :users, :admin

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class UpdateThemeFields < ActiveRecord::Migration[5.2]
def up
# CSS file related fields

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class RenameCropFields < ActiveRecord::Migration[5.2]
def change
rename_column :users, :crop_h, :profile_picture_h

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class RemovePaperclipFields < ActiveRecord::Migration[5.2]
def change
remove_column :users, :profile_picture_content_type

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
require 'securerandom'
require "securerandom"
# This migration changes the IDs of several tables from serial to a
# timestamped/"snowflake" one.
@ -13,7 +13,7 @@ class UseTimestampedIds < ActiveRecord::Migration[5.2]
def up
# PL/pgSQL is just spicy pascal
# don't @ me
execute <<~SQL
execute <<~SQL.squish
CREATE or replace FUNCTION gen_timestamp_id(tblname text) RETURNS bigint AS $$
DECLARE
timepart bigint;
@ -30,15 +30,15 @@ class UseTimestampedIds < ActiveRecord::Migration[5.2]
# we need to migrate related columns to bigints for this to work
{
question: %i[answers inboxes],
answer: %i[comments smiles subscriptions],
comment: %i[comment_smiles],
user: %i[announcements answers comment_smiles comments inboxes list_members lists moderation_comments moderation_votes questions reports services smiles subscriptions themes users_roles],
question: %i[answers inboxes],
answer: %i[comments smiles subscriptions],
comment: %i[comment_smiles],
user: %i[announcements answers comment_smiles comments inboxes list_members lists moderation_comments moderation_votes questions reports services smiles subscriptions themes users_roles],
# polymorphic tables go brrr
recipient: %i[notifications],
source: %i[relationships],
target: %i[notifications relationships reports],
source: %i[relationships],
target: %i[notifications relationships reports],
}.each do |ref, tbls|
tbls.each do |tbl|
say "Migrating #{tbl}.#{ref}_id to bigint"

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddOtpSecretKeyToUsers < ActiveRecord::Migration[5.2]
def change
add_column :users, :otp_secret_key, :string

View file

@ -1,9 +1,11 @@
# frozen_string_literal: true
class CreateTotpRecoveryCodes < ActiveRecord::Migration[5.2]
def change
create_table :totp_recovery_codes do |t|
t.bigint :user_id
t.string :code, limit: 8
end
add_index :totp_recovery_codes, [:user_id, :code]
add_index :totp_recovery_codes, %i[user_id code]
end
end

View file

@ -5,7 +5,7 @@ class AddDirectToQuestions < ActiveRecord::Migration[5.2]
add_column :questions, :direct, :boolean, null: false, default: false
# default all legacy questions to direct
execute 'UPDATE questions SET direct = true;'
execute "UPDATE questions SET direct = true;"
# All questions where
# - the author is not 'justask' (generated questions), and

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CreateUserBans < ActiveRecord::Migration[5.2]
def up
create_table :user_bans do |t|
@ -15,7 +17,6 @@ class CreateUserBans < ActiveRecord::Migration[5.2]
SELECT users.id, users.ban_reason, users.banned_until, users.updated_at, NOW() FROM users
WHERE banned_until IS NOT NULL AND NOT permanently_banned;"
execute "INSERT INTO user_bans
(user_id, reason, expires_at, created_at, updated_at)
SELECT users.id, users.ban_reason, NULL, users.updated_at, NOW() FROM users

View file

@ -1,18 +1,20 @@
# frozen_string_literal: true
class CreateProfiles < ActiveRecord::Migration[5.2]
def change
create_table :profiles do |t|
t.references :user, index: true, foreign_key: true
t.string :display_name, length: 50
t.string :description, length: 200, null: false, default: ''
t.string :location, length: 72, null: false, default: ''
t.string :website, null: false, default: ''
t.string :motivation_header, null: false, default: ''
t.string :description, length: 200, null: false, default: ""
t.string :location, length: 72, null: false, default: ""
t.string :website, null: false, default: ""
t.string :motivation_header, null: false, default: ""
t.timestamps
end
transaction do
execute 'INSERT INTO profiles (user_id, display_name, description, location, website, motivation_header, created_at, updated_at) SELECT users.id as user_id, users.display_name, users.bio as description, users.location, users.website, users.motivation_header, users.created_at, users.updated_at FROM users;'
execute "INSERT INTO profiles (user_id, display_name, description, location, website, motivation_header, created_at, updated_at) SELECT users.id as user_id, users.display_name, users.bio as description, users.location, users.website, users.motivation_header, users.created_at, users.updated_at FROM users;"
remove_column :users, :display_name
remove_column :users, :bio

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CreateMuteRules < ActiveRecord::Migration[5.2]
def change
create_table :mute_rules do |t|

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddIndexesToNotifications < ActiveRecord::Migration[5.2]
def change
add_index :notifications, :recipient_id

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddPostTagToServices < ActiveRecord::Migration[5.2]
def change
add_column :services, :post_tag, :string, limit: 20

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
@ -11,7 +13,6 @@
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2023_10_18_172518) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -51,8 +52,8 @@ ActiveRecord::Schema.define(version: 2023_10_18_172518) do
t.datetime "pinned_at"
t.index ["created_at"], name: "index_answers_on_created_at", order: :desc
t.index ["question_id"], name: "index_answers_on_question_id"
t.index ["user_id", "created_at"], name: "index_answers_on_user_id_and_created_at"
t.index ["user_id", "pinned_at"], name: "index_answers_on_user_id_and_pinned_at"
t.index %w[user_id created_at], name: "index_answers_on_user_id_and_created_at"
t.index %w[user_id pinned_at], name: "index_answers_on_user_id_and_pinned_at"
end
create_table "appendables", force: :cascade do |t|
@ -63,8 +64,8 @@ ActiveRecord::Schema.define(version: 2023_10_18_172518) do
t.text "content"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["parent_id", "parent_type"], name: "index_appendables_on_parent_id_and_parent_type"
t.index ["user_id", "created_at"], name: "index_appendables_on_user_id_and_created_at"
t.index %w[parent_id parent_type], name: "index_appendables_on_parent_id_and_parent_type"
t.index %w[user_id created_at], name: "index_appendables_on_user_id_and_created_at"
end
create_table "comments", id: :bigint, default: -> { "gen_timestamp_id('comments'::text)" }, force: :cascade do |t|
@ -75,7 +76,7 @@ ActiveRecord::Schema.define(version: 2023_10_18_172518) do
t.datetime "updated_at"
t.integer "smile_count", default: 0, null: false
t.index ["answer_id"], name: "index_comments_on_answer_id"
t.index ["user_id", "created_at"], name: "index_comments_on_user_id_and_created_at"
t.index %w[user_id created_at], name: "index_comments_on_user_id_and_created_at"
end
create_table "inboxes", id: :serial, force: :cascade do |t|
@ -93,7 +94,7 @@ ActiveRecord::Schema.define(version: 2023_10_18_172518) do
t.bigint "user_id", null: false
t.datetime "created_at"
t.datetime "updated_at"
t.index ["list_id", "user_id"], name: "index_list_members_on_list_id_and_user_id", unique: true
t.index %w[list_id user_id], name: "index_list_members_on_list_id_and_user_id", unique: true
end
create_table "lists", id: :serial, force: :cascade do |t|
@ -103,7 +104,7 @@ ActiveRecord::Schema.define(version: 2023_10_18_172518) do
t.boolean "private", default: true
t.datetime "created_at"
t.datetime "updated_at"
t.index ["user_id", "name"], name: "index_lists_on_user_id_and_name", unique: true
t.index %w[user_id name], name: "index_lists_on_user_id_and_name", unique: true
end
create_table "mute_rules", id: :bigint, default: -> { "gen_timestamp_id('mute_rules'::text)" }, force: :cascade do |t|
@ -150,7 +151,7 @@ ActiveRecord::Schema.define(version: 2023_10_18_172518) do
t.datetime "updated_at"
t.integer "answer_count", default: 0, null: false
t.boolean "direct", default: false, null: false
t.index ["user_id", "created_at"], name: "index_questions_on_user_id_and_created_at"
t.index %w[user_id created_at], name: "index_questions_on_user_id_and_created_at"
end
create_table "relationships", id: :serial, force: :cascade do |t|
@ -159,7 +160,7 @@ ActiveRecord::Schema.define(version: 2023_10_18_172518) do
t.datetime "created_at"
t.datetime "updated_at"
t.string "type", null: false
t.index ["source_id", "target_id", "type"], name: "index_relationships_on_source_id_and_target_id_and_type", unique: true
t.index %w[source_id target_id type], name: "index_relationships_on_source_id_and_target_id_and_type", unique: true
t.index ["source_id"], name: "index_relationships_on_source_id"
t.index ["target_id"], name: "index_relationships_on_target_id"
t.index ["type"], name: "index_relationships_on_type"
@ -173,8 +174,8 @@ ActiveRecord::Schema.define(version: 2023_10_18_172518) do
t.datetime "updated_at"
t.boolean "deleted", default: false
t.string "reason"
t.index ["type", "target_id"], name: "index_reports_on_type_and_target_id"
t.index ["user_id", "created_at"], name: "index_reports_on_user_id_and_created_at"
t.index %w[type target_id], name: "index_reports_on_type_and_target_id"
t.index %w[user_id created_at], name: "index_reports_on_user_id_and_created_at"
end
create_table "roles", force: :cascade do |t|
@ -183,8 +184,8 @@ ActiveRecord::Schema.define(version: 2023_10_18_172518) do
t.bigint "resource_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id"
t.index ["resource_type", "resource_id"], name: "index_roles_on_resource_type_and_resource_id"
t.index %w[name resource_type resource_id], name: "index_roles_on_name_and_resource_type_and_resource_id"
t.index %w[resource_type resource_id], name: "index_roles_on_resource_type_and_resource_id"
end
create_table "rpush_apps", force: :cascade do |t|
@ -253,7 +254,7 @@ ActiveRecord::Schema.define(version: 2023_10_18_172518) do
t.string "thread_id"
t.boolean "dry_run", default: false, null: false
t.boolean "sound_is_json", default: false
t.index ["delivered", "failed", "processing", "deliver_after", "created_at"], name: "index_rpush_notifications_multi", where: "((NOT delivered) AND (NOT failed))"
t.index %w[delivered failed processing deliver_after created_at], name: "index_rpush_notifications_multi", where: "((NOT delivered) AND (NOT failed))"
end
create_table "subscriptions", id: :serial, force: :cascade do |t|
@ -261,7 +262,7 @@ ActiveRecord::Schema.define(version: 2023_10_18_172518) do
t.bigint "answer_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["user_id", "answer_id"], name: "index_subscriptions_on_user_id_and_answer_id"
t.index %w[user_id answer_id], name: "index_subscriptions_on_user_id_and_answer_id"
end
create_table "themes", id: :serial, force: :cascade do |t|
@ -292,13 +293,13 @@ ActiveRecord::Schema.define(version: 2023_10_18_172518) do
t.integer "input_placeholder", default: 7107965, null: false
t.integer "raised_text", default: 0, null: false
t.integer "raised_accent_text", default: 0, null: false
t.index ["user_id", "created_at"], name: "index_themes_on_user_id_and_created_at"
t.index %w[user_id created_at], name: "index_themes_on_user_id_and_created_at"
end
create_table "totp_recovery_codes", force: :cascade do |t|
t.bigint "user_id"
t.string "code", limit: 8
t.index ["user_id", "code"], name: "index_totp_recovery_codes_on_user_id_and_code"
t.index %w[user_id code], name: "index_totp_recovery_codes_on_user_id_and_code"
end
create_table "user_bans", force: :cascade do |t|
@ -375,7 +376,7 @@ ActiveRecord::Schema.define(version: 2023_10_18_172518) do
t.bigint "user_id"
t.bigint "role_id"
t.index ["role_id"], name: "index_users_roles_on_role_id"
t.index ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id"
t.index %w[user_id role_id], name: "index_users_roles_on_user_id_and_role_id"
t.index ["user_id"], name: "index_users_roles_on_user_id"
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#