create urls

main
Alpha Chen 1 year ago
parent 69193b862d
commit 2101587102
Signed by: alpha
SSH Key Fingerprint: SHA256:3fOT8fiYQG/aK9ntivV3Bqtg8AYQ7q4nV6ZgihOA20g

@ -0,0 +1,31 @@
Sequel.migration do
up do
create_table(:urls) do
primary_key :id
foreign_key :entity_id, :entities, unique: true
String :url, unique: true, null: false
DateTime :created_at, null: false
DateTime :modified_at, null: false
end
json = Sequel.sqlite_json_op(:json)
href = json.extract("$.href")
DB[:pinboard]
.select_append(href.as(:href))
.each do |pin|
entity_id = pin.fetch(:entity_id)
url = pin.fetch(:href)
created_at = modified_at = DateTime.now
DB[:urls].insert(entity_id:, url:, created_at:, modified_at:)
end
end
down do
drop_table(:tags)
drop_table(:entities_tags)
end
end
Loading…
Cancel
Save