Deployment and lifecycle management for Nix
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

server: rename tree seed type

+236 -11
+11 -11
lib/sower/tree.ex
··· 4 4 domain: Sower, 5 5 extensions: [AshJsonApi.Resource] 6 6 7 - @derive {Jason.Encoder, only: [:id, :name, :type]} 7 + @derive {Jason.Encoder, only: [:id, :name, :seed_type]} 8 8 9 9 @types [:nixos, :"home-manager", :"nix-darwin"] 10 10 ··· 12 12 defaults [:read] 13 13 14 14 create :register do 15 - accept [:name, :type] 15 + accept [:name, :seed_type] 16 16 end 17 17 18 18 read :by_id do ··· 28 28 29 29 read :find do 30 30 argument :name, :string, allow_nil?: false 31 - argument :type, :string, allow_nil?: false 31 + argument :seed_type, :string, allow_nil?: false 32 32 33 33 get? true 34 34 35 - filter expr(name == ^arg(:name) && type == ^arg(:type)) 35 + filter expr(name == ^arg(:name) && seed_type == ^arg(:seed_type)) 36 36 end 37 37 38 38 create :set_system_seeds do ··· 55 55 booted_seed = 56 56 Sower.Seed.new( 57 57 booted_seed["name"], 58 - booted_seed["type"], 58 + booted_seed["seed_type"], 59 59 booted_seed["out_path"], 60 60 nil, 61 61 nil ··· 66 66 current_seed = 67 67 Sower.Seed.new( 68 68 current_seed["name"], 69 - current_seed["type"], 69 + current_seed["seed_type"], 70 70 current_seed["out_path"], 71 71 nil, 72 72 nil ··· 77 77 profile_seed = 78 78 Sower.Seed.new( 79 79 profile_seed["name"], 80 - profile_seed["type"], 80 + profile_seed["seed_type"], 81 81 profile_seed["out_path"], 82 82 nil, 83 83 nil ··· 101 101 public? true 102 102 end 103 103 104 - attribute :type, :atom do 104 + attribute :seed_type, :atom do 105 105 allow_nil? false 106 106 public? true 107 107 constraints one_of: @types ··· 110 110 111 111 code_interface do 112 112 define :by_id, args: [:id] 113 - define :find, args: [:name, :type] 113 + define :find, args: [:name, :seed_type] 114 114 define :set_system_seeds, args: [:profile_seed_id, :booted_seed_id, :current_seed_id] 115 115 define :read_all, action: :read 116 - define :register, args: [:name, :type] 116 + define :register, args: [:name, :seed_type] 117 117 end 118 118 119 119 identities do 120 - identity :tree, [:name, :type] 120 + identity :tree, [:name, :seed_type] 121 121 end 122 122 123 123 json_api do
+33
priv/repo/migrations/20240524170006_rename_seed_type.exs
··· 1 + defmodule Sower.Repo.Migrations.RenameSeedType do 2 + @moduledoc """ 3 + Updates resources based on their most recent snapshots. 4 + 5 + This file was autogenerated with `mix ash_postgres.generate_migrations` 6 + """ 7 + 8 + use Ecto.Migration 9 + 10 + def up do 11 + rename table(:trees), :type, to: :seed_type 12 + 13 + alter table(:trees) do 14 + modify :seed_type, :text 15 + end 16 + 17 + drop_if_exists unique_index(:trees, [:name, :type], name: "trees_tree_index") 18 + 19 + create unique_index(:trees, [:name, :seed_type], name: "trees_tree_index") 20 + end 21 + 22 + def down do 23 + drop_if_exists unique_index(:trees, [:name, :seed_type], name: "trees_tree_index") 24 + 25 + create unique_index(:trees, [:name, :type], name: "trees_tree_index") 26 + 27 + alter table(:trees) do 28 + modify :type, :text 29 + end 30 + 31 + rename table(:trees), :seed_type, to: :type 32 + end 33 + end
+192
priv/resource_snapshots/repo/trees/20240524170006.json
··· 1 + { 2 + "attributes": [ 3 + { 4 + "default": "fragment(\"gen_random_uuid()\")", 5 + "size": null, 6 + "type": "uuid", 7 + "source": "id", 8 + "references": null, 9 + "allow_nil?": false, 10 + "primary_key?": true, 11 + "generated?": false 12 + }, 13 + { 14 + "default": "fragment(\"(now() AT TIME ZONE 'utc')\")", 15 + "size": null, 16 + "type": "utc_datetime_usec", 17 + "source": "inserted_at", 18 + "references": null, 19 + "allow_nil?": false, 20 + "primary_key?": false, 21 + "generated?": false 22 + }, 23 + { 24 + "default": "fragment(\"(now() AT TIME ZONE 'utc')\")", 25 + "size": null, 26 + "type": "utc_datetime_usec", 27 + "source": "updated_at", 28 + "references": null, 29 + "allow_nil?": false, 30 + "primary_key?": false, 31 + "generated?": false 32 + }, 33 + { 34 + "default": "nil", 35 + "size": null, 36 + "type": "text", 37 + "source": "name", 38 + "references": null, 39 + "allow_nil?": false, 40 + "primary_key?": false, 41 + "generated?": false 42 + }, 43 + { 44 + "default": "nil", 45 + "size": null, 46 + "type": "text", 47 + "source": "seed_type", 48 + "references": null, 49 + "allow_nil?": false, 50 + "primary_key?": false, 51 + "generated?": false 52 + }, 53 + { 54 + "default": "nil", 55 + "size": null, 56 + "type": "uuid", 57 + "source": "booted_seed_id", 58 + "references": { 59 + "name": "trees_booted_seed_id_fkey", 60 + "table": "seeds", 61 + "primary_key?": true, 62 + "schema": "public", 63 + "multitenancy": { 64 + "global": null, 65 + "strategy": null, 66 + "attribute": null 67 + }, 68 + "destination_attribute": "id", 69 + "on_delete": null, 70 + "on_update": null, 71 + "deferrable": false, 72 + "match_with": null, 73 + "match_type": null, 74 + "destination_attribute_default": null, 75 + "destination_attribute_generated": null 76 + }, 77 + "allow_nil?": true, 78 + "primary_key?": false, 79 + "generated?": false 80 + }, 81 + { 82 + "default": "nil", 83 + "size": null, 84 + "type": "uuid", 85 + "source": "current_seed_id", 86 + "references": { 87 + "name": "trees_current_seed_id_fkey", 88 + "table": "seeds", 89 + "primary_key?": true, 90 + "schema": "public", 91 + "multitenancy": { 92 + "global": null, 93 + "strategy": null, 94 + "attribute": null 95 + }, 96 + "destination_attribute": "id", 97 + "on_delete": null, 98 + "on_update": null, 99 + "deferrable": false, 100 + "match_with": null, 101 + "match_type": null, 102 + "destination_attribute_default": null, 103 + "destination_attribute_generated": null 104 + }, 105 + "allow_nil?": true, 106 + "primary_key?": false, 107 + "generated?": false 108 + }, 109 + { 110 + "default": "nil", 111 + "size": null, 112 + "type": "uuid", 113 + "source": "latest_seed_id", 114 + "references": { 115 + "name": "trees_latest_seed_id_fkey", 116 + "table": "seeds", 117 + "primary_key?": true, 118 + "schema": "public", 119 + "multitenancy": { 120 + "global": null, 121 + "strategy": null, 122 + "attribute": null 123 + }, 124 + "destination_attribute": "id", 125 + "on_delete": null, 126 + "on_update": null, 127 + "deferrable": false, 128 + "match_with": null, 129 + "match_type": null, 130 + "destination_attribute_default": null, 131 + "destination_attribute_generated": null 132 + }, 133 + "allow_nil?": true, 134 + "primary_key?": false, 135 + "generated?": false 136 + }, 137 + { 138 + "default": "nil", 139 + "size": null, 140 + "type": "uuid", 141 + "source": "profile_seed_id", 142 + "references": { 143 + "name": "trees_profile_seed_id_fkey", 144 + "table": "seeds", 145 + "primary_key?": true, 146 + "schema": "public", 147 + "multitenancy": { 148 + "global": null, 149 + "strategy": null, 150 + "attribute": null 151 + }, 152 + "destination_attribute": "id", 153 + "on_delete": null, 154 + "on_update": null, 155 + "deferrable": false, 156 + "match_with": null, 157 + "match_type": null, 158 + "destination_attribute_default": null, 159 + "destination_attribute_generated": null 160 + }, 161 + "allow_nil?": true, 162 + "primary_key?": false, 163 + "generated?": false 164 + } 165 + ], 166 + "table": "trees", 167 + "hash": "7D07B884745BE10FFB6CA04DC82398D93FBA9FFB59EDE4FC798880EE17574507", 168 + "repo": "Elixir.Sower.Repo", 169 + "identities": [ 170 + { 171 + "name": "tree", 172 + "keys": [ 173 + "name", 174 + "seed_type" 175 + ], 176 + "base_filter": null, 177 + "all_tenants?": false, 178 + "index_name": "trees_tree_index" 179 + } 180 + ], 181 + "schema": null, 182 + "check_constraints": [], 183 + "custom_indexes": [], 184 + "multitenancy": { 185 + "global": null, 186 + "strategy": null, 187 + "attribute": null 188 + }, 189 + "base_filter": null, 190 + "custom_statements": [], 191 + "has_create_action": true 192 + }