added dmail test
This commit is contained in:
@@ -353,6 +353,44 @@ CREATE SEQUENCE comments_id_seq
|
||||
ALTER SEQUENCE comments_id_seq OWNED BY comments.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: dmails; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE TABLE dmails (
|
||||
id integer NOT NULL,
|
||||
owner_id integer NOT NULL,
|
||||
from_id integer NOT NULL,
|
||||
to_id integer NOT NULL,
|
||||
parent_id integer,
|
||||
title character varying(255) NOT NULL,
|
||||
body text NOT NULL,
|
||||
message_index tsvector NOT NULL,
|
||||
is_read boolean DEFAULT false NOT NULL,
|
||||
created_at timestamp without time zone,
|
||||
updated_at timestamp without time zone
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: dmails_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE dmails_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MAXVALUE
|
||||
NO MINVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: dmails_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE dmails_id_seq OWNED BY dmails.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: favorites_0; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
@@ -1245,6 +1283,13 @@ ALTER TABLE comment_votes ALTER COLUMN id SET DEFAULT nextval('comment_votes_id_
|
||||
ALTER TABLE comments ALTER COLUMN id SET DEFAULT nextval('comments_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE dmails ALTER COLUMN id SET DEFAULT nextval('dmails_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
|
||||
--
|
||||
@@ -1477,6 +1522,14 @@ ALTER TABLE ONLY comments
|
||||
ADD CONSTRAINT comments_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: dmails_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY dmails
|
||||
ADD CONSTRAINT dmails_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: favorites_0_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
@@ -1788,6 +1841,27 @@ CREATE INDEX index_comments_on_body_index ON comments USING gin (body_index);
|
||||
CREATE INDEX index_comments_on_post_id ON comments USING btree (post_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_dmails_on_message_index; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE INDEX index_dmails_on_message_index ON dmails USING gin (message_index);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_dmails_on_owner_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE INDEX index_dmails_on_owner_id ON dmails USING btree (owner_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_dmails_on_parent_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE INDEX index_dmails_on_parent_id ON dmails USING btree (parent_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_favorites_0_on_post_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
@@ -2151,6 +2225,16 @@ CREATE TRIGGER trigger_comments_on_update
|
||||
EXECUTE PROCEDURE tsvector_update_trigger('body_index', 'pg_catalog.english', 'body');
|
||||
|
||||
|
||||
--
|
||||
-- Name: trigger_dmails_on_update; Type: TRIGGER; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE TRIGGER trigger_dmails_on_update
|
||||
BEFORE INSERT OR UPDATE ON dmails
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE tsvector_update_trigger('message_index', 'pg_catalog.english', 'title', 'body');
|
||||
|
||||
|
||||
--
|
||||
-- Name: trigger_posts_on_tag_index_update; Type: TRIGGER; Schema: public; Owner: -
|
||||
--
|
||||
@@ -2217,4 +2301,6 @@ INSERT INTO schema_migrations (version) VALUES ('20100215224635');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20100215225710');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20100215230642');
|
||||
INSERT INTO schema_migrations (version) VALUES ('20100215230642');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20100219230537');
|
||||
26
db/migrate/20100219230537_create_dmails.rb
Normal file
26
db/migrate/20100219230537_create_dmails.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
class CreateDmails < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :dmails do |t|
|
||||
t.column :owner_id, :integer, :null => false
|
||||
t.column :from_id, :integer, :null => false
|
||||
t.column :to_id, :integer, :null => false
|
||||
t.column :parent_id, :integer
|
||||
t.column :title, :string, :null => false
|
||||
t.column :body, :text, :null => false
|
||||
t.column :message_index, "tsvector", :null => false
|
||||
t.column :is_read, :boolean, :null => false, :default => false
|
||||
t.column :is_deleted, :boolean, :null => false, :default => false
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :dmails, :owner_id
|
||||
add_index :dmails, :parent_id
|
||||
|
||||
execute "CREATE INDEX index_dmails_on_message_index ON dmails USING GIN (message_index)"
|
||||
execute "CREATE TRIGGER trigger_dmails_on_update BEFORE INSERT OR UPDATE ON dmails FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('message_index', 'pg_catalog.english', 'title', 'body')"
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :dmails
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user