You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
pinboard_export = File.expand_path(ENV.fetch("PINBOARD_EXPORT"))
|
|
|
|
|
|
|
|
Sequel.migration do
|
|
|
|
up do
|
|
|
|
create_table(:pinboard) do
|
|
|
|
primary_key :id
|
|
|
|
foreign_key :entity_id, :entities, null: false, unique: true
|
|
|
|
|
|
|
|
String :json, text: true, null: false
|
|
|
|
|
|
|
|
DateTime :created_at, null: false
|
|
|
|
DateTime :modified_at, null: false
|
|
|
|
end
|
|
|
|
|
|
|
|
File.foreach(pinboard_export).with_index do |line, i|
|
|
|
|
created_at = modified_at = DateTime.now
|
|
|
|
json = line.chomp
|
|
|
|
|
|
|
|
entity_id = DB[:entities].insert(created_at:, modified_at:)
|
|
|
|
DB[:pinboard].insert(entity_id:, json: , created_at:, modified_at:)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|