summaryrefslogtreecommitdiff
path: root/Rakefile
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2017-01-25 17:51:24 -0700
committermo khan <mo@mokhan.ca>2017-01-25 17:51:24 -0700
commit8ec14688124a4e3f65d916301f6994a26cfc324a (patch)
treef58978584db3dc79bdd0d074063ae56eea8de6f4 /Rakefile
parentc9ef265c99611ac0a49bfd4541684e5af968ac5f (diff)
generate seed data.
Diffstat (limited to 'Rakefile')
-rw-r--r--Rakefile13
1 files changed, 8 insertions, 5 deletions
diff --git a/Rakefile b/Rakefile
index 26443b5..1093661 100644
--- a/Rakefile
+++ b/Rakefile
@@ -3,6 +3,7 @@ require 'bundler'
Bundler.require(:default)
DATABASE_NAME = 'sql_bootcamp'
+DATABASE = Sequel.connect("mysql2://root@localhost/#{DATABASE_NAME}")
#| BUSINESSES | | COMPUTERS | | EVENTS | |
#| id | int | id | int | id | int |
@@ -29,18 +30,20 @@ namespace :db do
desc "Run migrations"
task :migrate, [:version] do |t, args|
Sequel.extension :migration
- db = Sequel.connect("mysql2://root@localhost/#{DATABASE_NAME}")
if args[:version]
puts "Migrating to version #{args[:version]}"
- Sequel::Migrator.run(db, "db/migrations", target: args[:version].to_i)
+ Sequel::Migrator.run(DATABASE, "db/migrations", target: args[:version].to_i)
else
puts "Migrating to latest"
- Sequel::Migrator.run(db, "db/migrations")
+ Sequel::Migrator.run(DATABASE, "db/migrations")
end
end
- task :reset => [:drop, :create, :migrate] do
-
+ task :seed do
+ require_relative 'db/seeds.rb'
end
+
+ desc "drop, create and migrate the database"
+ task :reset => [:drop, :create, :migrate, :seed]
end