-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit_users.rb
More file actions
executable file
·61 lines (52 loc) · 1.72 KB
/
init_users.rb
File metadata and controls
executable file
·61 lines (52 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env ruby
## Splay Controller ### v1.1 ###
## Copyright 2006-2011
## http://www.splay-project.org
##
##
##
## This file is part of Splay.
##
## Splayd is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published
## by the Free Software Foundation, either version 3 of the License,
## or (at your option) any later version.
##
## Splayd is distributed in the hope that it will be useful,but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
## See the GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Splayd. If not, see <http://www.gnu.org/licenses/>.
# GRANT ALL PRIVILEGES ON splay.* TO splay@localhost IDENTIFIED BY 'splay';
require File.expand_path(File.join(File.dirname(__FILE__), 'lib/all'))
def drop_db(db)
db.run("DROP TABLE IF EXISTS users")
end
def init_db(db)
db.run("CREATE TABLE IF NOT EXISTS users (
id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
login varchar(255) default NULL,
email varchar(255) default NULL,
crypted_password varchar(40) default NULL,
salt varchar(40) default NULL,
created_at datetime default NULL,
updated_at datetime default NULL,
remember_token varchar(255) default NULL,
remember_token_expires_at datetime default NULL,
admin int(11) default '0',
demo int(11) default '1'
);")
time_now = Time.new.strftime("%Y-%m-%d %T")
db.run("INSERT INTO users SET
login='admin',
crypted_password='d033e22ae348aeb5660fc2140aec35850c4da997',
created_at='#{time_now}',
admin=1,
demo=0")
end
db = DBUtils::get_new
drop_db(db)
init_db(db)
db.disconnect