mirror of
https://github.com/oonyeje/Pearlception_Website_RoR.git
synced 2025-12-25 11:47:41 +00:00
Add migrate runs script
This commit is contained in:
parent
4f1715023b
commit
c3e32ee7ba
@ -31,8 +31,8 @@ stats_test:
|
||||
development:
|
||||
<<: *default
|
||||
database: Pearlception_development
|
||||
username: colealban
|
||||
password: 1156244Terps!
|
||||
username: bmv
|
||||
password: 1156244terps!
|
||||
|
||||
# Warning: The database defined as "test" will be erased and
|
||||
# re-generated from your development database when you run "rake".
|
||||
|
||||
61
setup.rb
61
setup.rb
@ -4,8 +4,37 @@ require 'fileutils'
|
||||
|
||||
$company_data_endpoint = "companydata.c02zesysnssi.us-west-2.rds.amazonaws.com"
|
||||
|
||||
#A class to represent a run
|
||||
class Run
|
||||
|
||||
def initialize(params)
|
||||
@run_id = params["run_id"]
|
||||
@runDate = params["runDate"].strftime('%Y-%m-%d %H:%M:%S') || nil
|
||||
@location = params["location"] || "NULL"
|
||||
@supplier = params["supplier"] || "NULL"
|
||||
@other = params["other"] || "NULL"
|
||||
@machine_id = params["machine_id"] || "NULL"
|
||||
@harvest_time = params["harvest time"] || "NULL"
|
||||
@distributor = params["distributor"] || "NULL"
|
||||
end
|
||||
|
||||
def to_insert_query
|
||||
puts "#{@runDate}"
|
||||
"INSERT into runs (id, runDate, location, harvest_time, supplier, distributor, other, machine_id,created_at,updated_at) VALUES
|
||||
(#{@run_id}, '#{@runDate}',\"#{@location}\",NOW(),\"#{@supplier}\",\"#{@distributor}\",
|
||||
\"#{@other}\",#{@machine_id},NOW(),NOW());"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
#A class to represent a grade
|
||||
def Grade
|
||||
|
||||
def initialize(params)
|
||||
@id = params["grade_id"]
|
||||
@full_name = params["Full_Name"] || "NULL"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@ -31,14 +60,34 @@ def bundle
|
||||
end
|
||||
end
|
||||
|
||||
#This will insert the initial IVA admin needed to run the website.
|
||||
def setup_initial_admin
|
||||
client = Mysql2::Client.new(host:'localhost' ,username:"colealban", password:"1156244Terps!", database: "Pearlception_development")
|
||||
client = Mysql2::Client.new(host:'localhost' ,username:"colealban", password:"1156244terps!", database: "Pearlception_development")
|
||||
client.query("INSERT INTO companies (company_name, company_token, created_at, updated_at) VALUES (\"IVA\", \"a41b23cf-1d61-4fb4-9b69-0167abd7c583\",NOW(),NOW())")
|
||||
end
|
||||
|
||||
#This will migrate over all the runs that are on the AWS database to your local db
|
||||
def migrate_runs
|
||||
client = Mysql2::Client.new(host: $company_data_endpoint, username: 'ivauser', password: 'ivapassword', database: 'Hooper\'s Island')
|
||||
local_client = Mysql2::Client.new(host:'localhost' ,username:"bmv", password:"1156244terps!", database: "Pearlception_development")
|
||||
client.query("SELECT * FROM runs").each do |params|
|
||||
run = Run.new(params)
|
||||
puts run.to_insert_query
|
||||
local_client.query(run.to_insert_query)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
#This will migrate over all the oystersd
|
||||
def migrate_grades
|
||||
client = Mysql2::Client.new(host: $company_data_endpoint, username: 'ivauser', password: 'ivapassword', database: 'Hooper\'s Island')
|
||||
client.query("SELECT * FROM grades").each do |params|
|
||||
puts params
|
||||
end
|
||||
end
|
||||
|
||||
########## MAIN METHOD #####################
|
||||
bundle #bundle install
|
||||
initial_migration #Setup db
|
||||
setup_initial_admin
|
||||
#add in og admin
|
||||
#Migrate all the oysters,runs,results from the AWS DB
|
||||
#bundle #bundle install
|
||||
#initial_migration #Setup db
|
||||
#setup_initial_admin #Insert the initial admin
|
||||
migrate_grades #Migrate all the runs over
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user