* bootstrap tst user into db
This commit is contained in:
parent
b091740225
commit
db1c22917f
2
Gemfile
2
Gemfile
|
|
@ -7,4 +7,4 @@ workspace = ENV["WORKSPACE"] || "workspace"
|
|||
# $ cd [workspace]
|
||||
# $ git clone https://github.com/sethcall/pg_migrate_ruby
|
||||
|
||||
gem 'pg_migrate', '0.1.4' # :path=> '~/' + workspace + '/pg_migrate_ruby'
|
||||
gem 'pg_migrate', '0.1.5' # :path=> '~/' + workspace + '/pg_migrate_ruby'
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ GEM
|
|||
logging (1.7.2)
|
||||
little-plugger (>= 1.1.3)
|
||||
pg (0.14.0)
|
||||
pg_migrate (0.1.4)
|
||||
pg_migrate (0.1.5)
|
||||
logging (= 1.7.2)
|
||||
pg (= 0.14.0)
|
||||
thor (= 0.15.4)
|
||||
|
|
@ -15,4 +15,4 @@ PLATFORMS
|
|||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
pg_migrate (= 0.1.4)
|
||||
pg_migrate (= 0.1.5)
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ Then, to cause a migration, do something like:
|
|||
bundle install
|
||||
|
||||
# migrate the database (assumes you've created the 'jam' database already).
|
||||
bundle exec jam_db --connopts="dbname:jam host:localhost user:postgres password:postgres" --verbose
|
||||
bundle exec jam_db up --connopts="dbname:jam host:localhost user:postgres password:postgres" --verbose
|
||||
|
||||
# you can see if it worked by typing:
|
||||
|
||||
|
|
|
|||
|
|
@ -34,4 +34,30 @@ CREATE TABLE jam_session_members (
|
|||
|
||||
ALTER TABLE jam_session_members ADD CONSTRAINT user_jam_session_uniqkey UNIQUE (user_id, jam_session_id);
|
||||
|
||||
-- create a utility method to truncate all tables
|
||||
|
||||
CREATE OR REPLACE FUNCTION truncate_tables() RETURNS void AS $$
|
||||
DECLARE
|
||||
statements CURSOR FOR
|
||||
SELECT tablename FROM pg_tables
|
||||
WHERE schemaname = 'public';
|
||||
BEGIN
|
||||
FOR stmt IN statements LOOP
|
||||
EXECUTE 'TRUNCATE TABLE ' || quote_ident(stmt.tablename) || ' CASCADE;';
|
||||
END LOOP;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
-- create a utility that bootstraps a user
|
||||
CREATE OR REPLACE FUNCTION bootstrap_users() RETURNS void AS $$
|
||||
DECLARE
|
||||
|
||||
BEGIN
|
||||
-- non guid used for test user. test user won't be in actual database, but '1' is much easier to script that 242423-42-4-24234
|
||||
-- password is jam123
|
||||
INSERT INTO users (id, name, email, remember_token, password_digest) VALUES ('1', 'test', 'test@jamkazam.com', 'NQubl-z16Em94tnSdofObw', '$2a$10$QyaNTLVX5DAaJ.JL21kDWeUQqdh3Qh7JQbdRgE82x1Cib7HWNcHXC');
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
select bootstrap_users();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue