Last active
August 9, 2016 06:35
-
-
Save samcorcos/3f9f8ef9c2f0409c04636923384f7a1c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# priv/repo/set_subscription_renew.exs | |
# This script is run with: | |
# mix run priv/repo/set_subscription_renew.exs | |
alias LearnPhoenix.{Repo, User} | |
import Ecto.Query | |
set_subscription_renew = from(u in User, update: [set: [subscription_renew: true]]) | |
Repo.update_all(set_subscription_renew, []) | |
now = Ecto.DateTime.utc() | |
users = from(u in User, where: u.subscription_expiration < ^now) | |
Repo.update_all(users, set: [subscription_renew: false]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment