Skip to content

Instantly share code, notes, and snippets.

@asiniy
Last active August 11, 2016 11:17
Show Gist options
  • Save asiniy/eb8ffd48a60127d72cf7e0cd12259caf to your computer and use it in GitHub Desktop.
Save asiniy/eb8ffd48a60127d72cf7e0cd12259caf to your computer and use it in GitHub Desktop.
MyReelty migration commands
# rsync files
rsync -rv --include '*/' --include '*.jpg' --exclude '*' --prune-empty-dirs [email protected]:~/videos/ ~/
rsync -rv --prune-empty-dirs [email protected]:~/images/ ~/
# change backup
mix ecto.drop ; mix ecto.create ; psql my_reelty_dev < ~/development/my_reelty/production/backup.sql
# Remove all reviews except last 200
required_ids = Ecto.Query.from(r in Review, limit: 200, order_by: [desc: :id], select: [:id], where: is_nil(r.deleted_at)) |> Repo.all |> Enum.map(fn(r) -> r.id end)
Ecto.Query.from(r in Review, where: not(r.id in ^required_ids), order_by: [asc: :id]) |> Repo.update_all(set: [deleted_at: Ecto.DateTime.utc])
# First not-deleted video id
# => 25195 TODO fix this stuff before production migration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment