2023-01-21 23:39:49 +00:00
|
|
|
# This script connects to postgres, and exports all data as JSON files that the app expects
|
2022-12-26 00:21:39 +00:00
|
|
|
|
2023-01-21 23:39:49 +00:00
|
|
|
require './postgres.rb'
|
|
|
|
require 'neatjson'
|
2022-12-26 00:21:39 +00:00
|
|
|
|
2023-01-21 23:39:49 +00:00
|
|
|
# TODO: print one object on each line
|
2022-12-26 00:21:39 +00:00
|
|
|
File.open("topics.json","w") do |f|
|
2023-01-21 23:39:49 +00:00
|
|
|
f.write(
|
|
|
|
JSON.neat_generate(
|
|
|
|
JSON.parse(Topic.all.to_json),
|
|
|
|
wrap: 120
|
|
|
|
)
|
|
|
|
)
|
2022-12-26 00:21:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
File.open("creators.json","w") do |f|
|
2023-01-21 23:39:49 +00:00
|
|
|
f.write(
|
|
|
|
JSON.neat_generate(
|
|
|
|
JSON.parse(Creator.all.to_json),
|
|
|
|
wrap: 80
|
|
|
|
)
|
|
|
|
)
|
2022-12-26 00:21:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
File.open("items.json","w") do |f|
|
2023-01-21 23:39:49 +00:00
|
|
|
f.write(
|
|
|
|
JSON.neat_generate(
|
|
|
|
JSON.parse(Item.all.to_json),
|
|
|
|
wrap: 80
|
|
|
|
)
|
|
|
|
)
|
2022-12-26 00:21:39 +00:00
|
|
|
end
|
2023-01-21 23:39:49 +00:00
|
|
|
|
|
|
|
puts "Everything saved as JSON!"
|