Não use UUID como PK nas tabelas do seu banco de dados.
| MIT License | |
| Copyright (c) 2018 Noel Bundick | |
| Permission is hereby granted, free of charge, to any person obtaining a copy | |
| of this software and associated documentation files (the "Software"), to deal | |
| in the Software without restriction, including without limitation the rights | |
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| copies of the Software, and to permit persons to whom the Software is | |
| furnished to do so, subject to the following conditions: |
| defmodule DateTimeGenerators do | |
| use ExUnitProperties | |
| @time_zones ["Etc/UTC"] | |
| def date do | |
| gen all year <- integer(1970..2050), | |
| month <- integer(1..12), | |
| day <- integer(1..31), | |
| match?({:ok, _}, Date.from_erl({year, month, day})) do |
I recently wanted to rename a model and its postgres table in a Phoenix app. Renaming the table was simple and documented, but the table also had constraints, sequences, and indexes that needed to be updated in order for the Ecto model to be able to rely on default naming conventions. I couldn't find any examples of what this would look like but was eventually able to figure it out. For anyone else in the same situation, hopefully this example helps.
In the example below, I'm renaming the Permission model to Membership. This model belongs to a User and an Account, so it has foreign key constraints that need to be renamed.
defmodule MyApp.Repo.Migrations.RenamePermissionsToMemberships do
use Ecto.Migration
Around 2006-2007, it was a bit of a fashion to hook lava lamps up to the build server. Normally, the green lava lamp would be on, but if the build failed, it would turn off and the red lava lamp would turn on.
By coincidence, I've actually met, about that time, (probably) the first person to hook up a lava lamp to a build server. It was Alberto Savoia, who'd founded a testing tools company (that did some very interesting things around generative testing that have basically never been noticed). Alberto had noticed that people did not react with any urgency when the build broke. They'd check in broken code and go off to something else, only reacting to the breakage they'd caused when some other programmer pulled the change and had problems.
Make sure everything is up to date.
2. Install Xcode and its "Command Line Tools"
- Go to App Store and install Xcode.
- Open and accept the terms
| class BigDecimal | |
| def inspect | |
| format("#<BigDecimal:%x %s>", object_id, to_s('F')) | |
| end | |
| end |
| --colour | |
| -I app |
| [aaron@TC omglolwut (master)]$ cat lib/tasks/disable_autoload_during_migrations.rake | |
| task :disable_autoload do | |
| ActiveSupport::Dependencies.class_eval do | |
| extend Module.new { | |
| def load_file(path, const_paths = loadable_constants_for_path(path)) | |
| return if path.starts_with? File.join(Rails.application.root, 'app', 'models') | |
| super | |
| end | |
| } | |
| end |
| defmodule MyApp.Checks.UnverifiedMocks do | |
| @moduledoc """ | |
| #{__MODULE__} looks for test files that import Mox and use | |
| the `expect/4` function, but do not enforce any assertions that | |
| the expectations have been called or not either by running `verify_on_exit` | |
| from a setup block or calling `verify!/0` or `verify!/1` inline | |
| in a test block. | |
| """ | |
| @message """ |
