2022-12-26 00:21:39 +00:00
|
|
|
require 'pg'
|
|
|
|
require 'active_record'
|
|
|
|
require 'json'
|
|
|
|
|
|
|
|
class MyDB < ActiveRecord::Base
|
|
|
|
self.abstract_class = true
|
|
|
|
end
|
|
|
|
|
2022-12-26 04:35:44 +00:00
|
|
|
class Topic < MyDB; end
|
|
|
|
class Creator < MyDB; end
|
|
|
|
class Item < MyDB; end
|
2022-12-26 00:21:39 +00:00
|
|
|
|
|
|
|
ActiveRecord::Base.logger = Logger.new(STDERR)
|
|
|
|
|
|
|
|
ActiveRecord::Base.establish_connection(
|
|
|
|
{ adapter: 'postgresql',
|
|
|
|
database: 'postgres',
|
|
|
|
host: ENV['SUPABASE_HOST'],
|
|
|
|
username: 'postgres',
|
|
|
|
password: ENV['SUPABASE_PASSWORD'],
|
|
|
|
port: 6543
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
File.open("topics.json","w") do |f|
|
|
|
|
f.write(JSON.pretty_generate(JSON.parse(Topic.all.to_json)))
|
|
|
|
end
|
|
|
|
|
|
|
|
File.open("creators.json","w") do |f|
|
|
|
|
f.write(JSON.pretty_generate(JSON.parse(Creator.all.to_json)))
|
|
|
|
end
|
|
|
|
|
|
|
|
File.open("items.json","w") do |f|
|
|
|
|
f.write(JSON.pretty_generate(JSON.parse(Item.all.to_json)))
|
|
|
|
end
|