-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix push route for multiple routes change
- Loading branch information
1 parent
6f99cae
commit e492231
Showing
12 changed files
with
471 additions
and
27 deletions.
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
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,31 @@ | ||
defmodule TheronsErp.Inventory.ProductRoutes do | ||
use Ash.Resource, | ||
otp_app: :therons_erp, | ||
domain: TheronsErp.Inventory, | ||
data_layer: AshPostgres.DataLayer | ||
|
||
postgres do | ||
table "product_routes" | ||
repo TheronsErp.Repo | ||
end | ||
|
||
actions do | ||
read :read do | ||
primary? true | ||
end | ||
|
||
create :create do | ||
accept [:product_id, :routes_id] | ||
primary? true | ||
end | ||
|
||
destroy :destroy do | ||
primary? true | ||
end | ||
end | ||
|
||
relationships do | ||
belongs_to :product, TheronsErp.Inventory.Product, primary_key?: true, allow_nil?: false | ||
belongs_to :routes, TheronsErp.Inventory.Routes, primary_key?: true, allow_nil?: false | ||
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
55 changes: 55 additions & 0 deletions
55
priv/repo/migrations/20250225192853_many_to_many_routes.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,55 @@ | ||
defmodule TheronsErp.Repo.Migrations.ManyToManyRoutes 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 | ||
alter table(:products) do | ||
remove :route_id | ||
end | ||
|
||
create table(:product_routes, primary_key: false) do | ||
add :product_id, | ||
references(:products, | ||
column: :id, | ||
name: "product_routes_product_id_fkey", | ||
type: :uuid, | ||
prefix: "public" | ||
), | ||
primary_key: true, | ||
null: false | ||
|
||
add :routes_id, | ||
references(:routes, | ||
column: :id, | ||
name: "product_routes_routes_id_fkey", | ||
type: :uuid, | ||
prefix: "public" | ||
), | ||
primary_key: true, | ||
null: false | ||
end | ||
end | ||
|
||
def down do | ||
drop constraint(:product_routes, "product_routes_product_id_fkey") | ||
|
||
drop constraint(:product_routes, "product_routes_routes_id_fkey") | ||
|
||
drop table(:product_routes) | ||
|
||
alter table(:products) do | ||
add :route_id, | ||
references(:routes, | ||
column: :id, | ||
name: "products_route_id_fkey", | ||
type: :uuid, | ||
prefix: "public" | ||
) | ||
end | ||
end | ||
end |
Oops, something went wrong.