Ash codegen and migrate `undefined_table` when I have `many_to_many`

Hi sorry, I hope I haven't missed anything. These are some of my resources that use has_many, but I'm getting an error with the tables.
defmodule MishkaBlog.BlogPost do
postgres do
table "mishka_blog_posts"
repo MishkaCms.Repo
end
...

relationships do
belongs_to :site, MishkaCmsCoreResources.Runtime.Site do
allow_nil? false
public? true
end

many_to_many :tag, MishkaBlog.Tag do
through MishkaBlog.PostTag
source_attribute_on_join_resource :post_id
destination_attribute_on_join_resource :tag_id
end
end

defmodule MishkaBlog.Tag do
postgres do
table "mishka_blog_tags"
repo MishkaCms.Repo
end
...

relationships do
belongs_to :site, MishkaCmsCoreResources.Runtime.Site do
allow_nil? false
public? true
end

many_to_many :post, MishkaBlog.BlogPost do
through MishkaBlog.PostTag
source_attribute_on_join_resource :post_id
destination_attribute_on_join_resource :tag_id
end
end
end

defmodule MishkaBlog.PostTag do
postgres do
table "mishka_blog_post_tags"
repo MishkaCms.Repo
end
...

relationships do
belongs_to :post, MishkaBlog.BlogPost, primary_key?: true, allow_nil?: false
belongs_to :tag, MishkaBlog.Tag, primary_key?: true, allow_nil?: false
end
end
defmodule MishkaBlog.BlogPost do
postgres do
table "mishka_blog_posts"
repo MishkaCms.Repo
end
...

relationships do
belongs_to :site, MishkaCmsCoreResources.Runtime.Site do
allow_nil? false
public? true
end

many_to_many :tag, MishkaBlog.Tag do
through MishkaBlog.PostTag
source_attribute_on_join_resource :post_id
destination_attribute_on_join_resource :tag_id
end
end

defmodule MishkaBlog.Tag do
postgres do
table "mishka_blog_tags"
repo MishkaCms.Repo
end
...

relationships do
belongs_to :site, MishkaCmsCoreResources.Runtime.Site do
allow_nil? false
public? true
end

many_to_many :post, MishkaBlog.BlogPost do
through MishkaBlog.PostTag
source_attribute_on_join_resource :post_id
destination_attribute_on_join_resource :tag_id
end
end
end

defmodule MishkaBlog.PostTag do
postgres do
table "mishka_blog_post_tags"
repo MishkaCms.Repo
end
...

relationships do
belongs_to :post, MishkaBlog.BlogPost, primary_key?: true, allow_nil?: false
belongs_to :tag, MishkaBlog.Tag, primary_key?: true, allow_nil?: false
end
end
but i get this error and i do not know why :), i think i miss something .. 🥲
20:28:14.328 [info] create table mishka_blog_post_tags
** (Postgrex.Error) ERROR 42P01 (undefined_table) relation "public.mishka_blog_posts" does not exist
(ecto_sql 3.13.2) lib/ecto/adapters/sql.ex:1098: Ecto.Adapters.SQL.raise_sql_call_error/1
(elixir 1.18.4) lib/enum.ex:1714: Enum."-map/2-lists^map/1-1-"/2
(ecto_sql 3.13.2) lib/ecto/adapters/sql.ex:1219: Ecto.Adapters.SQL.execute_ddl/4
(ecto_sql 3.13.2) lib/ecto/migration/runner.ex:348: Ecto.Migration.Runner.log_and_execute_ddl/3
20:28:14.328 [info] create table mishka_blog_post_tags
** (Postgrex.Error) ERROR 42P01 (undefined_table) relation "public.mishka_blog_posts" does not exist
(ecto_sql 3.13.2) lib/ecto/adapters/sql.ex:1098: Ecto.Adapters.SQL.raise_sql_call_error/1
(elixir 1.18.4) lib/enum.ex:1714: Enum."-map/2-lists^map/1-1-"/2
(ecto_sql 3.13.2) lib/ecto/adapters/sql.ex:1219: Ecto.Adapters.SQL.execute_ddl/4
(ecto_sql 3.13.2) lib/ecto/migration/runner.ex:348: Ecto.Migration.Runner.log_and_execute_ddl/3
Thank you in advance
Solution:
i think i am an idiot,
Jump to solution
5 Replies
sevenseacat
sevenseacat•2mo ago
what migration did the codegen generate?
Shahryar
ShahryarOP•2mo ago
what dose it mean? the whole migration is huge!! 😂 but as i see this i can not find create table(:mishka_blog_posts) in it, but when i disable the many_to_many in the files it works!
sevenseacat
sevenseacat•2mo ago
how many resources are you generating, migrations shouldn't be huge :/
Shahryar
ShahryarOP•2mo ago
it is full blog system and cms and etc .. Oh oh, i disabled all of them !! and still i can not see the my table mishka_blog_posts
Solution
Shahryar
Shahryar•2mo ago
i think i am an idiot,

Did you find this page helpful?