mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
add proper post_uploads reverse index
This commit is contained in:
16
db/migrate/20130613211700_drop_posts_uploads.rb
Normal file
16
db/migrate/20130613211700_drop_posts_uploads.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
class DropPostsUploads < ActiveRecord::Migration
|
||||
def up
|
||||
drop_table :posts_uploads
|
||||
end
|
||||
|
||||
def down
|
||||
create_table :posts_uploads, id: false do |t|
|
||||
t.integer :post_id
|
||||
t.integer :upload_id
|
||||
end
|
||||
|
||||
add_index :posts_uploads, :post_id
|
||||
add_index :posts_uploads, :upload_id
|
||||
add_index :posts_uploads, [:post_id, :upload_id], unique: true
|
||||
end
|
||||
end
|
||||
15
db/migrate/20130613212230_create_post_uploads.rb
Normal file
15
db/migrate/20130613212230_create_post_uploads.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
class CreatePostUploads < ActiveRecord::Migration
|
||||
def up
|
||||
create_table :post_uploads do |t|
|
||||
t.integer :post_id, null: false
|
||||
t.integer :upload_id, null: false
|
||||
end
|
||||
|
||||
# no support for this till rails 4
|
||||
execute 'create unique index idx_unique_post_uploads on post_uploads(post_id, upload_id)'
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :post_uploads
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user