Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add mention of using :now in Time fields. #1239

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/actions/guides/database/migrations.cr
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ class Guides::Database::Migrations < GuideAction
add login_count : Int32, default: 0
add tags : Array(String)
add preferences : JSON::Any
add key : String, index: true
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't really related, but I wanted to sneak this in anyway to give an example that this is possible.

end
```

Expand Down Expand Up @@ -355,6 +356,8 @@ class Guides::Database::Migrations < GuideAction
alter table_for(User) do
# set all existing, and future users `active` to `true`
add active : Bool, default: true
# `:now` is a special symbol that casts to NOW() for Time columns
add active_at : Time, default: :now

# set all existing users `otp_code` to `"fake-otp-code-123".
# New users will require a value to be set.
Expand Down