added user test, basic user methods
This commit is contained in:
115
db/development_structure.sql
Normal file
115
db/development_structure.sql
Normal file
@@ -0,0 +1,115 @@
|
||||
--
|
||||
-- PostgreSQL database dump
|
||||
--
|
||||
|
||||
SET statement_timeout = 0;
|
||||
SET client_encoding = 'UTF8';
|
||||
SET standard_conforming_strings = off;
|
||||
SET check_function_bodies = false;
|
||||
SET client_min_messages = warning;
|
||||
SET escape_string_warning = off;
|
||||
|
||||
SET search_path = public, pg_catalog;
|
||||
|
||||
SET default_tablespace = '';
|
||||
|
||||
SET default_with_oids = false;
|
||||
|
||||
--
|
||||
-- Name: schema_migrations; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE TABLE schema_migrations (
|
||||
version character varying(255) NOT NULL
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: users; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE TABLE users (
|
||||
id integer NOT NULL,
|
||||
created_at timestamp without time zone,
|
||||
updated_at timestamp without time zone,
|
||||
name character varying(255) NOT NULL,
|
||||
password_hash character varying(255) NOT NULL,
|
||||
email character varying(255),
|
||||
invited_by integer,
|
||||
is_banned boolean DEFAULT false NOT NULL,
|
||||
is_privileged boolean DEFAULT false NOT NULL,
|
||||
is_contributor boolean DEFAULT false NOT NULL,
|
||||
is_janitor boolean DEFAULT false NOT NULL,
|
||||
is_moderator boolean DEFAULT false NOT NULL,
|
||||
is_admin boolean DEFAULT false NOT NULL,
|
||||
last_logged_in_at timestamp without time zone,
|
||||
last_forum_read_at timestamp without time zone,
|
||||
has_mail boolean DEFAULT false NOT NULL,
|
||||
receive_email_notifications boolean DEFAULT false NOT NULL,
|
||||
comment_threshold integer DEFAULT (-1) NOT NULL,
|
||||
always_resize_images boolean DEFAULT false NOT NULL,
|
||||
favorite_tags text,
|
||||
blacklisted_tags text
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE users_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MAXVALUE
|
||||
NO MINVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE users_id_seq OWNED BY users.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE users ALTER COLUMN id SET DEFAULT nextval('users_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: users_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY users
|
||||
ADD CONSTRAINT users_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_users_on_email; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE UNIQUE INDEX index_users_on_email ON users USING btree (email);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_users_on_name; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE UNIQUE INDEX index_users_on_name ON users USING btree (lower((name)::text));
|
||||
|
||||
|
||||
--
|
||||
-- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE UNIQUE INDEX unique_schema_migrations ON schema_migrations USING btree (version);
|
||||
|
||||
|
||||
--
|
||||
-- PostgreSQL database dump complete
|
||||
--
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20100204211522');
|
||||
37
db/migrate/20100204211522_create_users.rb
Normal file
37
db/migrate/20100204211522_create_users.rb
Normal file
@@ -0,0 +1,37 @@
|
||||
class CreateUsers < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :users do |t|
|
||||
t.timestamps
|
||||
|
||||
t.column :name, :string, :null => false
|
||||
t.column :password_hash, :string, :null => false
|
||||
t.column :email, :string
|
||||
t.column :invited_by, :integer
|
||||
t.column :is_banned, :boolean, :null => false, :default => false
|
||||
t.column :is_privileged, :boolean, :null => false, :default => false
|
||||
t.column :is_contributor, :boolean, :null => false, :default => false
|
||||
t.column :is_janitor, :boolean, :null => false, :default => false
|
||||
t.column :is_moderator, :boolean, :null => false, :default => false
|
||||
t.column :is_admin, :boolean, :null => false, :default => false
|
||||
|
||||
# Cached data
|
||||
t.column :last_logged_in_at, :datetime
|
||||
t.column :last_forum_read_at, :datetime
|
||||
t.column :has_mail, :boolean, :null => false, :default => false
|
||||
|
||||
# Profile settings
|
||||
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 :favorite_tags, :text
|
||||
t.column :blacklisted_tags, :text
|
||||
end
|
||||
|
||||
execute "CREATE UNIQUE INDEX index_users_on_name ON users ((lower(name)))"
|
||||
add_index :users, :email, :unique => true
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :users
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user