fixed tag and pending post tests, added category multiget helper to tag, post/unapproval/post version in progress still
This commit is contained in:
@@ -113,6 +113,42 @@ CREATE SEQUENCE pending_posts_id_seq
|
||||
ALTER SEQUENCE pending_posts_id_seq OWNED BY pending_posts.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: post_versions; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE TABLE post_versions (
|
||||
id integer NOT NULL,
|
||||
created_at timestamp without time zone,
|
||||
updated_at timestamp without time zone,
|
||||
post_id integer NOT NULL,
|
||||
source character varying(255),
|
||||
rating character(1) DEFAULT 'q'::bpchar NOT NULL,
|
||||
tag_string text NOT NULL,
|
||||
updater_id integer NOT NULL,
|
||||
updater_ip_addr inet NOT NULL
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: post_versions_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE post_versions_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MAXVALUE
|
||||
NO MINVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: post_versions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE post_versions_id_seq OWNED BY post_versions.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: posts; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
@@ -129,10 +165,13 @@ CREATE TABLE posts (
|
||||
is_rating_locked boolean DEFAULT false NOT NULL,
|
||||
is_pending boolean DEFAULT false NOT NULL,
|
||||
is_flagged boolean DEFAULT false NOT NULL,
|
||||
approver_id integer,
|
||||
change_seq integer DEFAULT 0,
|
||||
uploader_id integer NOT NULL,
|
||||
is_deleted boolean DEFAULT false NOT NULL,
|
||||
uploader_string character varying(255) NOT NULL,
|
||||
uploader_ip_addr inet NOT NULL,
|
||||
approver_string character varying(255) DEFAULT ''::character varying NOT NULL,
|
||||
fav_string text DEFAULT ''::text NOT NULL,
|
||||
pool_string text DEFAULT ''::text NOT NULL,
|
||||
view_count integer DEFAULT 0 NOT NULL,
|
||||
last_noted_at timestamp without time zone,
|
||||
last_commented_at timestamp without time zone,
|
||||
tag_string text NOT NULL,
|
||||
@@ -143,9 +182,9 @@ CREATE TABLE posts (
|
||||
tag_count_character integer DEFAULT 0 NOT NULL,
|
||||
tag_count_copyright integer DEFAULT 0 NOT NULL,
|
||||
file_ext character varying(255) NOT NULL,
|
||||
file_size integer NOT NULL,
|
||||
image_width integer NOT NULL,
|
||||
image_height integer NOT NULL,
|
||||
file_size integer NOT NULL
|
||||
image_height integer NOT NULL
|
||||
);
|
||||
|
||||
|
||||
@@ -185,6 +224,7 @@ CREATE TABLE tags (
|
||||
id integer NOT NULL,
|
||||
name character varying(255) NOT NULL,
|
||||
post_count integer DEFAULT 0 NOT NULL,
|
||||
view_count integer DEFAULT 0 NOT NULL,
|
||||
category integer DEFAULT 0 NOT NULL,
|
||||
related_tags text,
|
||||
created_at timestamp without time zone,
|
||||
@@ -211,6 +251,40 @@ CREATE SEQUENCE tags_id_seq
|
||||
ALTER SEQUENCE tags_id_seq OWNED BY tags.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: unapprovals; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE TABLE unapprovals (
|
||||
id integer NOT NULL,
|
||||
post_id integer NOT NULL,
|
||||
reason text,
|
||||
unapprover_id integer NOT NULL,
|
||||
unapprover_ip_addr inet NOT NULL,
|
||||
created_at timestamp without time zone,
|
||||
updated_at timestamp without time zone
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: unapprovals_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE unapprovals_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MAXVALUE
|
||||
NO MINVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: unapprovals_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE unapprovals_id_seq OWNED BY unapprovals.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: users; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
@@ -235,6 +309,7 @@ CREATE TABLE users (
|
||||
receive_email_notifications boolean DEFAULT false NOT NULL,
|
||||
comment_threshold integer DEFAULT (-1) NOT NULL,
|
||||
always_resize_images boolean DEFAULT false NOT NULL,
|
||||
default_image_size character varying(255) DEFAULT 'medium'::character varying NOT NULL,
|
||||
favorite_tags text,
|
||||
blacklisted_tags text
|
||||
);
|
||||
@@ -266,6 +341,13 @@ ALTER SEQUENCE users_id_seq OWNED BY users.id;
|
||||
ALTER TABLE pending_posts ALTER COLUMN id SET DEFAULT nextval('pending_posts_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE post_versions ALTER COLUMN id SET DEFAULT nextval('post_versions_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
|
||||
--
|
||||
@@ -280,6 +362,13 @@ ALTER TABLE posts ALTER COLUMN id SET DEFAULT nextval('posts_id_seq'::regclass);
|
||||
ALTER TABLE tags ALTER COLUMN id SET DEFAULT nextval('tags_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE unapprovals ALTER COLUMN id SET DEFAULT nextval('unapprovals_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
|
||||
--
|
||||
@@ -295,6 +384,14 @@ ALTER TABLE ONLY pending_posts
|
||||
ADD CONSTRAINT pending_posts_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: post_versions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY post_versions
|
||||
ADD CONSTRAINT post_versions_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: posts_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
@@ -311,6 +408,14 @@ ALTER TABLE ONLY tags
|
||||
ADD CONSTRAINT tags_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: unapprovals_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY unapprovals
|
||||
ADD CONSTRAINT unapprovals_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: users_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
@@ -320,17 +425,17 @@ ALTER TABLE ONLY users
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_posts_on_approver_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
-- Name: index_post_versions_on_post_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE INDEX index_posts_on_approver_id ON posts USING btree (approver_id);
|
||||
CREATE INDEX index_post_versions_on_post_id ON post_versions USING btree (post_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_posts_on_change_seq; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
-- Name: index_post_versions_on_updater_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE INDEX index_posts_on_change_seq ON posts USING btree (change_seq);
|
||||
CREATE INDEX index_post_versions_on_updater_id ON post_versions USING btree (updater_id);
|
||||
|
||||
|
||||
--
|
||||
@@ -404,10 +509,10 @@ CREATE INDEX index_posts_on_tags_index ON posts USING gin (tag_index);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_posts_on_uploader_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
-- Name: index_posts_on_view_count; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE INDEX index_posts_on_uploader_id ON posts USING btree (uploader_id);
|
||||
CREATE INDEX index_posts_on_view_count ON posts USING btree (view_count);
|
||||
|
||||
|
||||
--
|
||||
@@ -417,6 +522,13 @@ CREATE INDEX index_posts_on_uploader_id ON posts USING btree (uploader_id);
|
||||
CREATE UNIQUE INDEX index_tags_on_name ON tags USING btree (name);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_unapprovals_on_post_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE INDEX index_unapprovals_on_post_id ON unapprovals USING btree (post_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_users_on_email; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
@@ -445,7 +557,7 @@ CREATE UNIQUE INDEX unique_schema_migrations ON schema_migrations USING btree (v
|
||||
CREATE TRIGGER trigger_posts_on_tag_index_update
|
||||
BEFORE INSERT OR UPDATE ON posts
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE tsvector_update_trigger('tag_index', 'public.danbooru', 'tag_string');
|
||||
EXECUTE PROCEDURE tsvector_update_trigger('tag_index', 'public.danbooru', 'tag_string', 'fav_string', 'pool_string', 'uploader_string', 'approver_string');
|
||||
|
||||
|
||||
--
|
||||
@@ -458,4 +570,8 @@ INSERT INTO schema_migrations (version) VALUES ('20100204214746');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20100205162521');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20100205224030');
|
||||
INSERT INTO schema_migrations (version) VALUES ('20100205163027');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20100205224030');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20100209201251');
|
||||
@@ -23,6 +23,7 @@ class CreateUsers < ActiveRecord::Migration
|
||||
t.column :receive_email_notifications, :boolean, :null => false, :default => false
|
||||
t.column :comment_threshold, :integer, :null => false, :default => -1
|
||||
t.column :always_resize_images, :boolean, :null => false, :default => false
|
||||
t.column :default_image_size, :string, :null => false, :default => "medium"
|
||||
t.column :favorite_tags, :text
|
||||
t.column :blacklisted_tags, :text
|
||||
end
|
||||
|
||||
@@ -7,25 +7,34 @@ class CreatePosts < ActiveRecord::Migration
|
||||
t.column :source, :string
|
||||
t.column :md5, :string, :null => false
|
||||
t.column :rating, :character, :null => false, :default => 'q'
|
||||
|
||||
# Statuses
|
||||
t.column :is_note_locked, :boolean, :null => false, :default => false
|
||||
t.column :is_rating_locked, :boolean, :null => false, :default => false
|
||||
t.column :is_pending, :boolean, :null => false, :default => false
|
||||
t.column :is_flagged, :boolean, :null => false, :default => false
|
||||
t.column :is_deleted, :boolean, :null => false, :default => false
|
||||
t.column :approver_id, :integer
|
||||
t.column :change_seq, :integer, :default => "nextval('post_change_seq'::regclass)"
|
||||
|
||||
# Uploader
|
||||
t.column :uploader_id, :integer, :null => false
|
||||
t.column :uploader_string, :string, :null => false
|
||||
t.column :uploader_ip_addr, "inet", :null => false
|
||||
|
||||
# Approver
|
||||
t.column :approver_string, :string, :null => false, :default => ""
|
||||
|
||||
# Favorites
|
||||
t.column :fav_string, :text, :null => false, :default => ""
|
||||
|
||||
# Pools
|
||||
t.column :pool_string, :text, :null => false, :default => ""
|
||||
|
||||
# Cached
|
||||
t.column :fav_count, :integer
|
||||
t.column :view_count, :integer, :null => false, :default => 0
|
||||
t.column :last_noted_at, :datetime
|
||||
t.column :last_commented_at, :datetime
|
||||
|
||||
# Tags
|
||||
t.column :tag_string, :text, :null => false
|
||||
t.column :tag_string, :text, :null => false, :default => ""
|
||||
t.column :tag_index, "tsvector"
|
||||
t.column :tag_count, :integer, :null => false, :default => 0
|
||||
t.column :tag_count_general, :integer, :null => false, :default => 0
|
||||
@@ -35,22 +44,20 @@ class CreatePosts < ActiveRecord::Migration
|
||||
|
||||
# File
|
||||
t.column :file_ext, :string, :null => false
|
||||
t.column :file_size, :integer, :null => false
|
||||
t.column :image_width, :integer, :null => false
|
||||
t.column :image_height, :integer, :null => false
|
||||
t.column :file_size, :integer, :null => false
|
||||
end
|
||||
|
||||
add_index :posts, :md5, :unique => true
|
||||
add_index :posts, :created_at
|
||||
add_index :posts, :last_commented_at
|
||||
add_index :posts, :last_noted_at
|
||||
add_index :posts, :uploader_id
|
||||
add_index :posts, :approver_id
|
||||
add_index :posts, :change_seq
|
||||
add_index :posts, :file_size
|
||||
add_index :posts, :image_width
|
||||
add_index :posts, :image_height
|
||||
add_index :posts, :source
|
||||
add_index :posts, :view_count
|
||||
|
||||
execute "CREATE INDEX index_posts_on_mpixels ON posts (((image_width * image_height)::numeric / 1000000.0))"
|
||||
|
||||
@@ -89,7 +96,7 @@ class CreatePosts < ActiveRecord::Migration
|
||||
execute "CREATE TEXT SEARCH CONFIGURATION public.danbooru (PARSER = public.testparser)"
|
||||
execute "ALTER TEXT SEARCH CONFIGURATION public.danbooru ADD MAPPING FOR WORD WITH SIMPLE"
|
||||
execute "SET default_text_search_config = 'public.danbooru'"
|
||||
execute "CREATE TRIGGER trigger_posts_on_tag_index_update BEFORE INSERT OR UPDATE ON posts FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('tag_index', 'public.danbooru', 'tag_string')"
|
||||
execute "CREATE TRIGGER trigger_posts_on_tag_index_update BEFORE INSERT OR UPDATE ON posts FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('tag_index', 'public.danbooru', 'tag_string', 'fav_string', 'pool_string', 'uploader_string', 'approver_string')"
|
||||
end
|
||||
|
||||
def self.down
|
||||
|
||||
@@ -3,6 +3,7 @@ class CreateTags < ActiveRecord::Migration
|
||||
create_table :tags do |t|
|
||||
t.column :name, :string, :null => false
|
||||
t.column :post_count, :integer, :null => false, :default => 0
|
||||
t.column :view_count, :integer, :null => false, :default => 0
|
||||
t.column :category, :integer, :null => false, :default => 0
|
||||
t.column :related_tags, :text
|
||||
t.timestamps
|
||||
|
||||
26
db/migrate/20100205163027_create_post_versions.rb
Normal file
26
db/migrate/20100205163027_create_post_versions.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
class CreatePostVersions < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :post_versions do |t|
|
||||
t.timestamps
|
||||
|
||||
# Post
|
||||
t.column :post_id, :integer, :null => false
|
||||
|
||||
# Versioned
|
||||
t.column :source, :string
|
||||
t.column :rating, :character, :null => false, :default => 'q'
|
||||
t.column :tag_string, :text, :null => false
|
||||
|
||||
# Updater
|
||||
t.column :updater_id, :integer, :null => false
|
||||
t.column :updater_ip_addr, "inet", :null => false
|
||||
end
|
||||
|
||||
add_index :post_versions, :post_id
|
||||
add_index :post_versions, :updater_id
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :post_versions
|
||||
end
|
||||
end
|
||||
17
db/migrate/20100209201251_create_unapprovals.rb
Normal file
17
db/migrate/20100209201251_create_unapprovals.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
class CreateUnapprovals < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :unapprovals do |t|
|
||||
t.column :post_id, :integer, :null => false
|
||||
t.column :reason, :text
|
||||
t.column :unapprover_id, :integer, :null => false
|
||||
t.column :unapprover_ip_addr, "inet", :null => false
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :unapprovals, :post_id
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :unapprovals
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user