added notes

This commit is contained in:
albert
2010-02-24 15:40:55 -05:00
parent 7bb935256b
commit 55700efeb1
17 changed files with 462 additions and 27 deletions

View File

@@ -0,0 +1,25 @@
class CreateNotes < ActiveRecord::Migration
def self.up
create_table :notes do |t|
t.column :creator_id, :integer, :null => false
t.column :post_id, :integer, :null => false
t.column :x, :integer, :null => false
t.column :y, :integer, :null => false
t.column :width, :integer, :null => false
t.column :height, :integer, :null => false
t.column :is_active, :boolean, :null => false, :default => true
t.column :body, :text, :null => false
t.column :text_index, "tsvector", :null => false
t.timestamps
end
add_index :notes, :creator_id
add_index :notes, :post_id
execute "CREATE INDEX index_notes_on_text_index ON notes USING GIN (text_index)"
execute "CREATE TRIGGER trigger_notes_on_update BEFORE INSERT OR UPDATE ON notes FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('text_index', 'pg_catalog.english', 'body')"
end
def self.down
drop_table :notes
end
end

View File

@@ -0,0 +1,23 @@
class CreateNoteVersions < ActiveRecord::Migration
def self.up
create_table :note_versions do |t|
t.column :note_id, :integer, :null => false
t.column :updater_id, :integer, :null => false
t.column :updater_ip_addr, "inet", :null => false
t.column :x, :integer, :null => false
t.column :y, :integer, :null => false
t.column :width, :integer, :null => false
t.column :height, :integer, :null => false
t.column :is_active, :boolean, :null => false, :default => true
t.column :body, :text, :null => false
t.timestamps
end
add_index :note_versions, :note_id
add_index :note_versions, :updater_id
end
def self.down
drop_table :note_versions
end
end