defmodule Ammoprices.Repo.Migrations.AddNewRetailers do use Ecto.Migration def up do now = DateTime.utc_now() |> DateTime.truncate(:second) |> DateTime.to_naive() retailers = [ %{name: "True Shot Ammo", slug: "true-shot-ammo", base_url: "https://trueshotammo.com"}, %{ name: "Palmetto State Armory", slug: "palmetto-state-armory", base_url: "https://palmettostatearmory.com" }, %{name: "Bulk Ammo", slug: "bulk-ammo", base_url: "https://www.bulkammo.com"}, %{ name: "Natchez Shooters Supply", slug: "natchez", base_url: "https://www.natchezss.com" } ] for r <- retailers do execute(""" INSERT INTO retailers (id, name, slug, base_url, inserted_at, updated_at) VALUES (gen_random_uuid(), '#{r.name}', '#{r.slug}', '#{r.base_url}', '#{now}', '#{now}') ON CONFLICT (slug) DO NOTHING """) end end def down do execute( "DELETE FROM retailers WHERE slug IN ('true-shot-ammo', 'palmetto-state-armory', 'bulk-ammo', 'natchez')" ) end end