added artists, comments

This commit is contained in:
albert
2010-02-15 13:59:58 -05:00
parent 3d9d6e229a
commit e9c2d1e636
28 changed files with 1044 additions and 7 deletions

View 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

View 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

View 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

View 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

View 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

View 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