added artists, comments
This commit is contained in:
21
db/migrate/20100213181847_create_comments.rb
Normal file
21
db/migrate/20100213181847_create_comments.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
class CreateComments < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :comments do |t|
|
||||
t.column :post_id, :integer, :null => false
|
||||
t.column :creator_id, :integer, :null => false
|
||||
t.column :body, :text, :null => false
|
||||
t.column :ip_addr, "inet", :null => false
|
||||
t.column :body_index, "tsvector", :null => false
|
||||
t.column :score, :integer, :null => false, :default => 0
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :comments, :post_id
|
||||
execute "CREATE INDEX index_comments_on_body_index ON comments USING GIN (body_index)"
|
||||
execute "CREATE TRIGGER trigger_comments_on_update BEFORE INSERT OR UPDATE ON comments FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('body_index', 'pg_catalog.english', 'body')"
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :comments
|
||||
end
|
||||
end
|
||||
15
db/migrate/20100213183712_create_comment_votes.rb
Normal file
15
db/migrate/20100213183712_create_comment_votes.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
class CreateCommentVotes < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :comment_votes do |t|
|
||||
t.column :comment_id, :integer, :null => false
|
||||
t.column :user_id, :integer, :null => false
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :comment_votes, :user_id
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :comment_votes
|
||||
end
|
||||
end
|
||||
22
db/migrate/20100214080549_create_artists.rb
Normal file
22
db/migrate/20100214080549_create_artists.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
class CreateArtists < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :artists do |t|
|
||||
t.column :name, :string, :null => false
|
||||
t.column :creator_id, :integer, :null => false
|
||||
t.column :is_active, :boolean, :null => false, :default => true
|
||||
t.column :other_names, :text
|
||||
t.column :other_names_index, "tsvector"
|
||||
t.column :group_name, :string
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :artists, :name, :unique => true
|
||||
add_index :artists, :group_name
|
||||
execute "CREATE INDEX index_artists_on_other_names_index ON artists USING GIN (other_names_index)"
|
||||
execute "CREATE TRIGGER trigger_artists_on_update BEFORE INSERT OR UPDATE ON artists FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('other_names_index', 'public.danbooru', 'other_names')"
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :artists
|
||||
end
|
||||
end
|
||||
23
db/migrate/20100214080557_create_artist_versions.rb
Normal file
23
db/migrate/20100214080557_create_artist_versions.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
class CreateArtistVersions < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :artist_versions do |t|
|
||||
t.column :artist_id, :integer, :null => false
|
||||
t.column :name, :string, :null => false
|
||||
t.column :updater_id, :integer, :null => false
|
||||
t.column :updater_ip_addr, "inet", :null => false
|
||||
t.column :is_active, :boolean, :null => false, :default => true
|
||||
t.column :other_names, :text
|
||||
t.column :group_name, :string
|
||||
t.column :url_string, :text
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :artist_versions, :artist_id
|
||||
add_index :artist_versions, :name
|
||||
add_index :artist_versions, :updater_id
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :artist_versions
|
||||
end
|
||||
end
|
||||
17
db/migrate/20100214080605_create_artist_urls.rb
Normal file
17
db/migrate/20100214080605_create_artist_urls.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
class CreateArtistUrls < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :artist_urls do |t|
|
||||
t.column :artist_id, :integer, :null => false
|
||||
t.column :url, :text, :null => false
|
||||
t.column :normalized_url, :text, :null => false
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :artist_urls, :artist_id
|
||||
add_index :artist_urls, :normalized_url
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :artist_urls
|
||||
end
|
||||
end
|
||||
20
db/migrate/20100215182234_create_wiki_pages.rb
Normal file
20
db/migrate/20100215182234_create_wiki_pages.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
class CreateWikiPages < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :wiki_pages do |t|
|
||||
t.column :creator_id, :integer, :null => false
|
||||
t.column :title, :string, :null => false
|
||||
t.column :body, :text, :null => false
|
||||
t.column :body_index, "tsvector", :null => false
|
||||
t.column :is_locked, :boolean, :null => false, :default => false
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :wiki_pages, :title, :unique => true
|
||||
execute "CREATE INDEX index_wiki_pages_on_body_index_index ON wiki_pages USING GIN (body_index)"
|
||||
execute "CREATE TRIGGER trigger_wiki_pages_on_update BEFORE INSERT OR UPDATE ON wiki_pages FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('body_index', 'public.danbooru', 'body', 'title')"
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :wiki_pages
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user