added notes
This commit is contained in:
@@ -797,6 +797,84 @@ CREATE SEQUENCE jobs_id_seq
|
||||
ALTER SEQUENCE jobs_id_seq OWNED BY jobs.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: note_versions; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE TABLE note_versions (
|
||||
id integer NOT NULL,
|
||||
note_id integer NOT NULL,
|
||||
updater_id integer NOT NULL,
|
||||
updater_ip_addr inet NOT NULL,
|
||||
x integer NOT NULL,
|
||||
y integer NOT NULL,
|
||||
width integer NOT NULL,
|
||||
height integer NOT NULL,
|
||||
is_active boolean DEFAULT true NOT NULL,
|
||||
body text NOT NULL,
|
||||
created_at timestamp without time zone,
|
||||
updated_at timestamp without time zone
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: note_versions_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE note_versions_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MAXVALUE
|
||||
NO MINVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: note_versions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE note_versions_id_seq OWNED BY note_versions.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: notes; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE TABLE notes (
|
||||
id integer NOT NULL,
|
||||
creator_id integer NOT NULL,
|
||||
post_id integer NOT NULL,
|
||||
x integer NOT NULL,
|
||||
y integer NOT NULL,
|
||||
width integer NOT NULL,
|
||||
height integer NOT NULL,
|
||||
is_active boolean DEFAULT true NOT NULL,
|
||||
body text NOT NULL,
|
||||
text_index tsvector NOT NULL,
|
||||
created_at timestamp without time zone,
|
||||
updated_at timestamp without time zone
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: notes_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE notes_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MAXVALUE
|
||||
NO MINVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: notes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE notes_id_seq OWNED BY notes.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: pool_versions; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
@@ -1520,6 +1598,20 @@ ALTER TABLE forum_topics ALTER COLUMN id SET DEFAULT nextval('forum_topics_id_se
|
||||
ALTER TABLE jobs ALTER COLUMN id SET DEFAULT nextval('jobs_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE note_versions ALTER COLUMN id SET DEFAULT nextval('note_versions_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE notes ALTER COLUMN id SET DEFAULT nextval('notes_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
|
||||
--
|
||||
@@ -1801,6 +1893,22 @@ ALTER TABLE ONLY jobs
|
||||
ADD CONSTRAINT jobs_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: note_versions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY note_versions
|
||||
ADD CONSTRAINT note_versions_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: notes_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY notes
|
||||
ADD CONSTRAINT notes_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: pool_versions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
@@ -2236,6 +2344,41 @@ CREATE INDEX index_forum_topics_on_creator_id ON forum_topics USING btree (creat
|
||||
CREATE INDEX index_forum_topics_on_text_index ON forum_topics USING gin (text_index);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_note_versions_on_note_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE INDEX index_note_versions_on_note_id ON note_versions USING btree (note_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_note_versions_on_updater_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE INDEX index_note_versions_on_updater_id ON note_versions USING btree (updater_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_notes_on_creator_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE INDEX index_notes_on_creator_id ON notes USING btree (creator_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_notes_on_post_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE INDEX index_notes_on_post_id ON notes USING btree (post_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_notes_on_text_index; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE INDEX index_notes_on_text_index ON notes USING gin (text_index);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_pool_versions_on_pool_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
@@ -2503,6 +2646,16 @@ CREATE TRIGGER trigger_forum_topics_on_update
|
||||
EXECUTE PROCEDURE tsvector_update_trigger('text_index', 'pg_catalog.english', 'title');
|
||||
|
||||
|
||||
--
|
||||
-- Name: trigger_notes_on_update; Type: TRIGGER; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
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');
|
||||
|
||||
|
||||
--
|
||||
-- Name: trigger_posts_on_tag_index_update; Type: TRIGGER; Schema: public; Owner: -
|
||||
--
|
||||
@@ -2579,4 +2732,8 @@ INSERT INTO schema_migrations (version) VALUES ('20100221005812');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20100221012656');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20100223001012');
|
||||
INSERT INTO schema_migrations (version) VALUES ('20100223001012');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20100224171915');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20100224172146');
|
||||
25
db/migrate/20100224171915_create_notes.rb
Normal file
25
db/migrate/20100224171915_create_notes.rb
Normal 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
|
||||
23
db/migrate/20100224172146_create_note_versions.rb
Normal file
23
db/migrate/20100224172146_create_note_versions.rb
Normal 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
|
||||
Reference in New Issue
Block a user