about summary refs log tree commit diff
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20181207011115_downcase_custom_emoji_domains.rb10
-rw-r--r--db/migrate/20181226021420_add_also_known_as_to_accounts.rb5
-rw-r--r--db/migrate/20190103124649_create_scheduled_statuses.rb9
-rw-r--r--db/migrate/20190103124754_add_scheduled_status_id_to_media_attachments.rb8
-rw-r--r--db/schema.rb15
-rw-r--r--db/seeds.rb2
6 files changed, 46 insertions, 3 deletions
diff --git a/db/migrate/20181207011115_downcase_custom_emoji_domains.rb b/db/migrate/20181207011115_downcase_custom_emoji_domains.rb
index c9db3800d..65f1fc8d9 100644
--- a/db/migrate/20181207011115_downcase_custom_emoji_domains.rb
+++ b/db/migrate/20181207011115_downcase_custom_emoji_domains.rb
@@ -1,7 +1,15 @@
 class DowncaseCustomEmojiDomains < ActiveRecord::Migration[5.2]
   disable_ddl_transaction!
 
-  def change
+  def up
+    duplicates = CustomEmoji.connection.select_all('SELECT string_agg(id::text, \',\') AS ids FROM custom_emojis GROUP BY shortcode, lower(domain) HAVING count(*) > 1').to_hash
+
+    duplicates.each do |row|
+      CustomEmoji.where(id: row['ids'].split(',')[0...-1]).destroy_all
+    end
+
     CustomEmoji.in_batches.update_all('domain = lower(domain)')
   end
+
+  def down; end
 end
diff --git a/db/migrate/20181226021420_add_also_known_as_to_accounts.rb b/db/migrate/20181226021420_add_also_known_as_to_accounts.rb
new file mode 100644
index 000000000..1fd956680
--- /dev/null
+++ b/db/migrate/20181226021420_add_also_known_as_to_accounts.rb
@@ -0,0 +1,5 @@
+class AddAlsoKnownAsToAccounts < ActiveRecord::Migration[5.2]
+  def change
+    add_column :accounts, :also_known_as, :string, array: true
+  end
+end
diff --git a/db/migrate/20190103124649_create_scheduled_statuses.rb b/db/migrate/20190103124649_create_scheduled_statuses.rb
new file mode 100644
index 000000000..2b78073b8
--- /dev/null
+++ b/db/migrate/20190103124649_create_scheduled_statuses.rb
@@ -0,0 +1,9 @@
+class CreateScheduledStatuses < ActiveRecord::Migration[5.2]
+  def change
+    create_table :scheduled_statuses do |t|
+      t.belongs_to :account, foreign_key: { on_delete: :cascade }
+      t.datetime :scheduled_at, index: true
+      t.jsonb :params
+    end
+  end
+end
diff --git a/db/migrate/20190103124754_add_scheduled_status_id_to_media_attachments.rb b/db/migrate/20190103124754_add_scheduled_status_id_to_media_attachments.rb
new file mode 100644
index 000000000..6f6cf2351
--- /dev/null
+++ b/db/migrate/20190103124754_add_scheduled_status_id_to_media_attachments.rb
@@ -0,0 +1,8 @@
+class AddScheduledStatusIdToMediaAttachments < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def change
+    add_reference :media_attachments, :scheduled_status, foreign_key: { on_delete: :nullify }, index: false
+    add_index :media_attachments, :scheduled_status_id, algorithm: :concurrently
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 48ffea3dd..2836ff91f 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
 #
 # It's strongly recommended that you check this file into your version control system.
 
-ActiveRecord::Schema.define(version: 2018_12_19_235220) do
+ActiveRecord::Schema.define(version: 2019_01_03_124754) do
 
   # These are extensions that must be enabled in order to support this database
   enable_extension "plpgsql"
@@ -134,6 +134,7 @@ ActiveRecord::Schema.define(version: 2018_12_19_235220) do
     t.jsonb "fields"
     t.string "actor_type"
     t.boolean "discoverable"
+    t.string "also_known_as", array: true
     t.index "(((setweight(to_tsvector('simple'::regconfig, (display_name)::text), 'A'::\"char\") || setweight(to_tsvector('simple'::regconfig, (username)::text), 'B'::\"char\")) || setweight(to_tsvector('simple'::regconfig, (COALESCE(domain, ''::character varying))::text), 'C'::\"char\")))", name: "search_index", using: :gin
     t.index "lower((username)::text), lower((domain)::text)", name: "index_accounts_on_username_and_domain_lower", unique: true
     t.index ["moved_to_account_id"], name: "index_accounts_on_moved_to_account_id"
@@ -346,7 +347,9 @@ ActiveRecord::Schema.define(version: 2018_12_19_235220) do
     t.json "file_meta"
     t.bigint "account_id"
     t.text "description"
+    t.bigint "scheduled_status_id"
     t.index ["account_id"], name: "index_media_attachments_on_account_id"
+    t.index ["scheduled_status_id"], name: "index_media_attachments_on_scheduled_status_id"
     t.index ["shortcode"], name: "index_media_attachments_on_shortcode", unique: true
     t.index ["status_id"], name: "index_media_attachments_on_status_id"
   end
@@ -497,6 +500,14 @@ ActiveRecord::Schema.define(version: 2018_12_19_235220) do
     t.index ["target_account_id"], name: "index_reports_on_target_account_id"
   end
 
+  create_table "scheduled_statuses", force: :cascade do |t|
+    t.bigint "account_id"
+    t.datetime "scheduled_at"
+    t.jsonb "params"
+    t.index ["account_id"], name: "index_scheduled_statuses_on_account_id"
+    t.index ["scheduled_at"], name: "index_scheduled_statuses_on_scheduled_at"
+  end
+
   create_table "session_activations", force: :cascade do |t|
     t.string "session_id", null: false
     t.datetime "created_at", null: false
@@ -713,6 +724,7 @@ ActiveRecord::Schema.define(version: 2018_12_19_235220) do
   add_foreign_key "list_accounts", "lists", on_delete: :cascade
   add_foreign_key "lists", "accounts", on_delete: :cascade
   add_foreign_key "media_attachments", "accounts", name: "fk_96dd81e81b", on_delete: :nullify
+  add_foreign_key "media_attachments", "scheduled_statuses", on_delete: :nullify
   add_foreign_key "media_attachments", "statuses", on_delete: :nullify
   add_foreign_key "mentions", "accounts", name: "fk_970d43f9d1", on_delete: :cascade
   add_foreign_key "mentions", "statuses", on_delete: :cascade
@@ -731,6 +743,7 @@ ActiveRecord::Schema.define(version: 2018_12_19_235220) do
   add_foreign_key "reports", "accounts", column: "assigned_account_id", on_delete: :nullify
   add_foreign_key "reports", "accounts", column: "target_account_id", name: "fk_eb37af34f0", on_delete: :cascade
   add_foreign_key "reports", "accounts", name: "fk_4b81f7522c", on_delete: :cascade
+  add_foreign_key "scheduled_statuses", "accounts", on_delete: :cascade
   add_foreign_key "session_activations", "oauth_access_tokens", column: "access_token_id", name: "fk_957e5bda89", on_delete: :cascade
   add_foreign_key "session_activations", "users", name: "fk_e5fda67334", on_delete: :cascade
   add_foreign_key "status_pins", "accounts", name: "fk_d4cb435b62", on_delete: :cascade
diff --git a/db/seeds.rb b/db/seeds.rb
index 6adfeed8d..cf62ebf39 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -4,5 +4,5 @@ if Rails.env.development?
   domain = ENV['LOCAL_DOMAIN'] || Rails.configuration.x.local_domain
   admin  = Account.where(username: 'admin').first_or_initialize(username: 'admin')
   admin.save(validate: false)
-  User.where(email: "admin@#{domain}").first_or_initialize(email: "admin@#{domain}", password: 'mastodonadmin', password_confirmation: 'mastodonadmin', confirmed_at: Time.now.utc, admin: true, account: admin).save!
+  User.where(email: "admin@#{domain}").first_or_initialize(email: "admin@#{domain}", password: 'mastodonadmin', password_confirmation: 'mastodonadmin', confirmed_at: Time.now.utc, admin: true, account: admin, agreement: true).save!
 end