update reference to postgres? in the migrations too
This commit is contained in:
parent
d07073cf8e
commit
b8db623aa4
7 changed files with 10 additions and 10 deletions
|
|
@ -10,7 +10,7 @@ class AddFullNameToProfile < ActiveRecord::Migration
|
||||||
remove_index :profiles, [:last_name, :searchable]
|
remove_index :profiles, [:last_name, :searchable]
|
||||||
|
|
||||||
if Profile.count > 0
|
if Profile.count > 0
|
||||||
if postgres?
|
if AppConfig.postgres?
|
||||||
execute("UPDATE profiles SET full_name=LOWER(first_name || ' ' || last_name)")
|
execute("UPDATE profiles SET full_name=LOWER(first_name || ' ' || last_name)")
|
||||||
else
|
else
|
||||||
execute("UPDATE profiles SET full_name=LOWER(CONCAT(first_name, ' ', last_name))")
|
execute("UPDATE profiles SET full_name=LOWER(CONCAT(first_name, ' ', last_name))")
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ class ShareAnything < ActiveRecord::Migration
|
||||||
def self.up
|
def self.up
|
||||||
remove_foreign_key :aspect_visibilities, :posts
|
remove_foreign_key :aspect_visibilities, :posts
|
||||||
|
|
||||||
if postgres?
|
if AppConfig.postgres?
|
||||||
execute "DROP INDEX index_aspect_visibilities_on_post_id_and_aspect_id"
|
execute "DROP INDEX index_aspect_visibilities_on_post_id_and_aspect_id"
|
||||||
execute "DROP INDEX index_aspect_visibilities_on_post_id"
|
execute "DROP INDEX index_aspect_visibilities_on_post_id"
|
||||||
execute "ALTER TABLE aspect_visibilities RENAME COLUMN post_id TO shareable_id"
|
execute "ALTER TABLE aspect_visibilities RENAME COLUMN post_id TO shareable_id"
|
||||||
|
|
@ -46,7 +46,7 @@ class ShareAnything < ActiveRecord::Migration
|
||||||
remove_foreign_key :post_visibilities, :posts
|
remove_foreign_key :post_visibilities, :posts
|
||||||
rename_table :post_visibilities, :share_visibilities
|
rename_table :post_visibilities, :share_visibilities
|
||||||
|
|
||||||
if postgres?
|
if AppConfig.postgres?
|
||||||
execute "DROP INDEX index_post_visibilities_on_contact_id_and_post_id"
|
execute "DROP INDEX index_post_visibilities_on_contact_id_and_post_id"
|
||||||
execute "DROP INDEX index_post_visibilities_on_post_id_and_hidden_and_contact_id"
|
execute "DROP INDEX index_post_visibilities_on_post_id_and_hidden_and_contact_id"
|
||||||
execute "ALTER TABLE share_visibilities RENAME COLUMN post_id TO shareable_id"
|
execute "ALTER TABLE share_visibilities RENAME COLUMN post_id TO shareable_id"
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ class MovePhotosToTheirOwnTable < ActiveRecord::Migration
|
||||||
t.integer "comments_count"
|
t.integer "comments_count"
|
||||||
end
|
end
|
||||||
|
|
||||||
if postgres?
|
if AppConfig.postgres?
|
||||||
execute %{
|
execute %{
|
||||||
INSERT INTO photos (
|
INSERT INTO photos (
|
||||||
tmp_old_id
|
tmp_old_id
|
||||||
|
|
@ -82,7 +82,7 @@ SQL
|
||||||
|
|
||||||
|
|
||||||
def self.down
|
def self.down
|
||||||
if postgres?
|
if AppConfig.postgres?
|
||||||
execute %{
|
execute %{
|
||||||
INSERT INTO posts (
|
INSERT INTO posts (
|
||||||
id, author_id, public, diaspora_handle, guid, pending, type, text,
|
id, author_id, public, diaspora_handle, guid, pending, type, text,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
class PostgresqlPhotosIdSeqInit < ActiveRecord::Migration
|
class PostgresqlPhotosIdSeqInit < ActiveRecord::Migration
|
||||||
def self.up
|
def self.up
|
||||||
if postgres?
|
if AppConfig.postgres?
|
||||||
execute "SELECT setval('photos_id_seq', COALESCE( ( SELECT MAX(id)+1 FROM photos ), 1 ) )"
|
execute "SELECT setval('photos_id_seq', COALESCE( ( SELECT MAX(id)+1 FROM photos ), 1 ) )"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ class FixPhotoShareVisibilities < ActiveRecord::Migration
|
||||||
def self.up
|
def self.up
|
||||||
return if ! Photo.first.respond_to?(:tmp_old_id)
|
return if ! Photo.first.respond_to?(:tmp_old_id)
|
||||||
|
|
||||||
if postgres?
|
if AppConfig.postgres?
|
||||||
['aspect_visibilities', 'share_visibilities'].each do |vis_table|
|
['aspect_visibilities', 'share_visibilities'].each do |vis_table|
|
||||||
execute "UPDATE #{vis_table} SET shareable_type = 'Post'"
|
execute "UPDATE #{vis_table} SET shareable_type = 'Post'"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ class CounterCacheOnPostReshares < ActiveRecord::Migration
|
||||||
def self.up
|
def self.up
|
||||||
add_column :posts, :reshares_count, :integer, :default => 0
|
add_column :posts, :reshares_count, :integer, :default => 0
|
||||||
|
|
||||||
if postgres?
|
if AppConfig.postgres?
|
||||||
execute %{
|
execute %{
|
||||||
UPDATE posts
|
UPDATE posts
|
||||||
SET reshares_count = (
|
SET reshares_count = (
|
||||||
|
|
|
||||||
|
|
@ -16,14 +16,14 @@ class RemovePublicShareVisibilities < ActiveRecord::Migration
|
||||||
index = 0
|
index = 0
|
||||||
|
|
||||||
table_name = type.tableize
|
table_name = type.tableize
|
||||||
if postgres?
|
if AppConfig.postgres?
|
||||||
shareable_size = ActiveRecord::Base.connection.execute("SELECT COUNT(*) FROM #{table_name}").first['count'].to_i
|
shareable_size = ActiveRecord::Base.connection.execute("SELECT COUNT(*) FROM #{table_name}").first['count'].to_i
|
||||||
else
|
else
|
||||||
shareable_size = ActiveRecord::Base.connection.execute("SELECT COUNT(*) FROM #{table_name}").first.first
|
shareable_size = ActiveRecord::Base.connection.execute("SELECT COUNT(*) FROM #{table_name}").first.first
|
||||||
end
|
end
|
||||||
|
|
||||||
while index < shareable_size + 100 do
|
while index < shareable_size + 100 do
|
||||||
if postgres?
|
if AppConfig.postgres?
|
||||||
sql = <<-SQL
|
sql = <<-SQL
|
||||||
DELETE
|
DELETE
|
||||||
FROM share_visibilities AS sv
|
FROM share_visibilities AS sv
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue