-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ability to bulk migrate agents to new versions (#502)
- Loading branch information
1 parent
2f16dff
commit 6fdaefc
Showing
6 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
defmodule Console.Schema.AgentMigration do | ||
use Piazza.Ecto.Schema | ||
|
||
schema "agent_migrations" do | ||
field :completed, :boolean, default: false | ||
|
||
timestamps() | ||
end | ||
|
||
def incomplete(query \\ __MODULE__), do: from(am in query, where: not am.completed) | ||
|
||
def changeset(model, attrs \\ %{}) do | ||
model | ||
|> cast(attrs, [:completed]) | ||
end | ||
end |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
defmodule Console.Repo.Migrations.AgentMigrations do | ||
use Ecto.Migration | ||
|
||
def change do | ||
create table(:agent_migrations, primary_key: false) do | ||
add :id, :uuid, primary_key: true | ||
add :completed, :boolean, default: false | ||
|
||
timestamps() | ||
end | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Botanist | ||
|
||
alias Console.Schema.AgentMigration | ||
|
||
seed do | ||
%AgentMigration{} | ||
|> AgentMigration.changeset() | ||
|> Console.Repo.insert() | ||
end |