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.
31 lines
683 B
31 lines
683 B
1 year ago
|
Sequel.migration do
|
||
|
up do
|
||
|
create_table(:urls) do
|
||
|
primary_key :id
|
||
1 year ago
|
foreign_key :entity_id, :entities, null: false, unique: true
|
||
1 year ago
|
|
||
|
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
|
||
1 year ago
|
drop_table(:urls)
|
||
1 year ago
|
end
|
||
|
end
|