tag unit test
This commit is contained in:
@@ -24,6 +24,40 @@ CREATE TABLE schema_migrations (
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: tags; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE TABLE tags (
|
||||
id integer NOT NULL,
|
||||
name character varying(255) NOT NULL,
|
||||
post_count integer DEFAULT 0 NOT NULL,
|
||||
category integer DEFAULT 0 NOT NULL,
|
||||
related_tags text,
|
||||
created_at timestamp without time zone,
|
||||
updated_at timestamp without time zone
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: tags_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE tags_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MAXVALUE
|
||||
NO MINVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: tags_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE tags_id_seq OWNED BY tags.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: users; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
@@ -72,6 +106,13 @@ CREATE SEQUENCE users_id_seq
|
||||
ALTER SEQUENCE users_id_seq OWNED BY users.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE tags ALTER COLUMN id SET DEFAULT nextval('tags_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
|
||||
--
|
||||
@@ -79,6 +120,14 @@ ALTER SEQUENCE users_id_seq OWNED BY users.id;
|
||||
ALTER TABLE users ALTER COLUMN id SET DEFAULT nextval('users_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY tags
|
||||
ADD CONSTRAINT tags_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: users_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
@@ -87,6 +136,13 @@ ALTER TABLE ONLY users
|
||||
ADD CONSTRAINT users_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_tags_on_name; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE UNIQUE INDEX index_tags_on_name ON tags USING btree (name);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_users_on_email; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
@@ -112,4 +168,6 @@ CREATE UNIQUE INDEX unique_schema_migrations ON schema_migrations USING btree (v
|
||||
-- PostgreSQL database dump complete
|
||||
--
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20100204211522');
|
||||
INSERT INTO schema_migrations (version) VALUES ('20100204211522');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20100205162521');
|
||||
17
db/migrate/20100205162521_create_tags.rb
Normal file
17
db/migrate/20100205162521_create_tags.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
class CreateTags < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :tags do |t|
|
||||
t.column :name, :string, :null => false
|
||||
t.column :post_count, :integer, :null => false, :default => 0
|
||||
t.column :category, :integer, :null => false, :default => 0
|
||||
t.column :related_tags, :text
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :tags, :name, :unique => true
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :tags
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user