-
Notifications
You must be signed in to change notification settings - Fork 116
/
Rakefile
53 lines (45 loc) · 2.22 KB
/
Rakefile
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
require 'rake'
require 'rspec/core/rake_task'
require_relative 'db/config'
require_relative 'lib/students_importer'
require_relative 'app/models/teacher'
desc "create the database"
task "db:create" do
touch 'db/ar-students.sqlite3'
end
desc "drop the database"
task "db:drop" do
rm_f 'db/ar-students.sqlite3'
end
desc "migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)."
task "db:migrate" do
ActiveRecord::Migrator.migrations_paths << File.dirname(__FILE__) + 'db/migrate'
ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
ActiveRecord::Migrator.migrate(ActiveRecord::Migrator.migrations_paths, ENV["VERSION"] ? ENV["VERSION"].to_i : nil) do |migration|
ENV["SCOPE"].blank? || (ENV["SCOPE"] == migration.scope)
end
end
desc "populate the students database with sample data"
task "db:populate" do
StudentsImporter.import
end
desc "populate the teachers database with sample data"
task "db:populate_teacher" do
Teacher.create(first_name: 'Dill', last_name: "Barracuda", email: "[email protected]", phone: "1234567890")
Teacher.create(first_name: 'Master', last_name: "Teng", email: "[email protected]", phone: "1255557890")
Teacher.create(first_name: 'Jambu', last_name: "Air", email: "[email protected]", phone: "0123456789")
Teacher.create(first_name: 'Orang', last_name: "Minyak", email: "[email protected]", phone: "0123446789")
Teacher.create(first_name: 'Lori', last_name: "Ayam", email: "[email protected]", phone: "1123456789")
Teacher.create(first_name: 'Makan', last_name: "Nasi", email: "[email protected]", phone: "1234588890")
Teacher.create(first_name: 'Pandu', last_name: "Kuda", email: "[email protected]", phone: "1234566790")
Teacher.create(first_name: 'Takde', last_name: "Nama", email: "[email protected]", phone: "0123345625")
Teacher.create(first_name: 'Susah', last_name: "Fikir", email: "[email protected]", phone: "6544385532")
Teacher.create(first_name: 'Lapar', last_name: "Pagi", email: "[email protected]", phone: "5598634298")
end
desc 'Retrieves the current schema version number'
task "db:version" do
puts "Current version: #{ActiveRecord::Migrator.current_version}"
end
desc "Run the specs"
RSpec::Core::RakeTask.new(:specs)
task :default => :specs