-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(containers): better create release error
- creating a new release with a version already in use complains about the `:version` and not about the `:application_id` - added tests to check the error messages and related fields - generated migrations with `mix ash_postgres.generate_migrations version_release_identity` Signed-off-by: Luca Zaninotto <[email protected]>
- Loading branch information
Showing
5 changed files
with
510 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
57 changes: 57 additions & 0 deletions
57
backend/priv/repo/migrations/20241127111957_version_release_identity.exs
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,57 @@ | ||
# | ||
# This file is part of Edgehog. | ||
# | ||
# Copyright 2024 SECO Mind Srl | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
defmodule Edgehog.Repo.Migrations.VersionReleaseIdentity do | ||
@moduledoc """ | ||
Updates resources based on their most recent snapshots. | ||
This file was autogenerated with `mix ash_postgres.generate_migrations` | ||
""" | ||
|
||
use Ecto.Migration | ||
|
||
def up do | ||
drop_if_exists unique_index(:application_releases, [:tenant_id, :application_id, :version], | ||
name: "application_releases_application_version_index" | ||
) | ||
|
||
create unique_index(:application_releases, [:tenant_id, :version, :application_id], | ||
name: "application_releases_application_version_index" | ||
) | ||
|
||
alter table(:application_deployments) do | ||
modify :status, :text, null: false, default: "created" | ||
end | ||
end | ||
|
||
def down do | ||
alter table(:application_deployments) do | ||
modify :status, :text, null: true, default: nil | ||
end | ||
|
||
drop_if_exists unique_index(:application_releases, [:tenant_id, :version, :application_id], | ||
name: "application_releases_application_version_index" | ||
) | ||
|
||
create unique_index(:application_releases, [:tenant_id, :application_id, :version], | ||
name: "application_releases_application_version_index" | ||
) | ||
end | ||
end |
225 changes: 225 additions & 0 deletions
225
backend/priv/resource_snapshots/repo/application_deployments/20241127111957.json
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,225 @@ | ||
{ | ||
"attributes": [ | ||
{ | ||
"allow_nil?": false, | ||
"default": "fragment(\"gen_random_uuid()\")", | ||
"generated?": false, | ||
"primary_key?": true, | ||
"references": null, | ||
"size": null, | ||
"source": "id", | ||
"type": "uuid" | ||
}, | ||
{ | ||
"allow_nil?": false, | ||
"default": "\"created\"", | ||
"generated?": false, | ||
"primary_key?": false, | ||
"references": null, | ||
"size": null, | ||
"source": "status", | ||
"type": "text" | ||
}, | ||
{ | ||
"allow_nil?": true, | ||
"default": "nil", | ||
"generated?": false, | ||
"primary_key?": false, | ||
"references": null, | ||
"size": null, | ||
"source": "message", | ||
"type": "text" | ||
}, | ||
{ | ||
"allow_nil?": false, | ||
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")", | ||
"generated?": false, | ||
"primary_key?": false, | ||
"references": null, | ||
"size": null, | ||
"source": "inserted_at", | ||
"type": "utc_datetime_usec" | ||
}, | ||
{ | ||
"allow_nil?": false, | ||
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")", | ||
"generated?": false, | ||
"primary_key?": false, | ||
"references": null, | ||
"size": null, | ||
"source": "updated_at", | ||
"type": "utc_datetime_usec" | ||
}, | ||
{ | ||
"allow_nil?": false, | ||
"default": "nil", | ||
"generated?": false, | ||
"primary_key?": false, | ||
"references": { | ||
"deferrable": false, | ||
"destination_attribute": "tenant_id", | ||
"destination_attribute_default": null, | ||
"destination_attribute_generated": null, | ||
"index?": false, | ||
"match_type": null, | ||
"match_with": null, | ||
"multitenancy": { | ||
"attribute": null, | ||
"global": null, | ||
"strategy": null | ||
}, | ||
"name": "application_deployments_tenant_id_fkey", | ||
"on_delete": "delete", | ||
"on_update": null, | ||
"primary_key?": true, | ||
"schema": "public", | ||
"table": "tenants" | ||
}, | ||
"size": null, | ||
"source": "tenant_id", | ||
"type": "bigint" | ||
}, | ||
{ | ||
"allow_nil?": true, | ||
"default": "nil", | ||
"generated?": false, | ||
"primary_key?": false, | ||
"references": { | ||
"deferrable": false, | ||
"destination_attribute": "id", | ||
"destination_attribute_default": null, | ||
"destination_attribute_generated": null, | ||
"index?": false, | ||
"match_type": null, | ||
"match_with": null, | ||
"multitenancy": { | ||
"attribute": "tenant_id", | ||
"global": false, | ||
"strategy": "attribute" | ||
}, | ||
"name": "application_deployments_device_id_fkey", | ||
"on_delete": "delete", | ||
"on_update": null, | ||
"primary_key?": true, | ||
"schema": "public", | ||
"table": "devices" | ||
}, | ||
"size": null, | ||
"source": "device_id", | ||
"type": "bigint" | ||
}, | ||
{ | ||
"allow_nil?": true, | ||
"default": "nil", | ||
"generated?": false, | ||
"primary_key?": false, | ||
"references": { | ||
"deferrable": false, | ||
"destination_attribute": "id", | ||
"destination_attribute_default": null, | ||
"destination_attribute_generated": null, | ||
"index?": false, | ||
"match_type": null, | ||
"match_with": null, | ||
"multitenancy": { | ||
"attribute": "tenant_id", | ||
"global": false, | ||
"strategy": "attribute" | ||
}, | ||
"name": "application_deployments_release_id_fkey", | ||
"on_delete": null, | ||
"on_update": null, | ||
"primary_key?": true, | ||
"schema": "public", | ||
"table": "application_releases" | ||
}, | ||
"size": null, | ||
"source": "release_id", | ||
"type": "uuid" | ||
} | ||
], | ||
"base_filter": null, | ||
"check_constraints": [], | ||
"custom_indexes": [ | ||
{ | ||
"all_tenants?": true, | ||
"concurrently": false, | ||
"error_fields": [ | ||
"id", | ||
"tenant_id" | ||
], | ||
"fields": [ | ||
{ | ||
"type": "atom", | ||
"value": "id" | ||
}, | ||
{ | ||
"type": "atom", | ||
"value": "tenant_id" | ||
} | ||
], | ||
"include": null, | ||
"message": null, | ||
"name": null, | ||
"nulls_distinct": true, | ||
"prefix": null, | ||
"table": null, | ||
"unique": true, | ||
"using": null, | ||
"where": null | ||
}, | ||
{ | ||
"all_tenants?": true, | ||
"concurrently": false, | ||
"error_fields": [ | ||
"tenant_id" | ||
], | ||
"fields": [ | ||
{ | ||
"type": "atom", | ||
"value": "tenant_id" | ||
} | ||
], | ||
"include": null, | ||
"message": null, | ||
"name": null, | ||
"nulls_distinct": true, | ||
"prefix": null, | ||
"table": null, | ||
"unique": false, | ||
"using": null, | ||
"where": null | ||
} | ||
], | ||
"custom_statements": [], | ||
"has_create_action": true, | ||
"hash": "6F3F4DD9AD9BE71582025656C1B3876F375AD9C0A274517D90B867E70BE4ACB6", | ||
"identities": [ | ||
{ | ||
"all_tenants?": false, | ||
"base_filter": null, | ||
"index_name": "application_deployments_release_instance_index", | ||
"keys": [ | ||
{ | ||
"type": "atom", | ||
"value": "device_id" | ||
}, | ||
{ | ||
"type": "atom", | ||
"value": "release_id" | ||
} | ||
], | ||
"name": "release_instance", | ||
"nils_distinct?": true, | ||
"where": null | ||
} | ||
], | ||
"multitenancy": { | ||
"attribute": "tenant_id", | ||
"global": false, | ||
"strategy": "attribute" | ||
}, | ||
"repo": "Elixir.Edgehog.Repo", | ||
"schema": null, | ||
"table": "application_deployments" | ||
} |
Oops, something went wrong.