-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate Mermaid Diagrams for Your Database #84
Comments
Isn't Ecto.ERD good enough for your usage? |
@ndrean great question. Probably. Thanks for the reminder. 🎉 |
exports to mermaid but I don't like these diagrams. Dot is ok. |
I made a "self reminder post" on this |
@ndrean great post. Thanks for making it and sharing. 🚀 |
I do this kind of post just for myself because I tend to forget so glad it is understandable. For your use case, it's just 2 lines in the terminal: |
In return, any guidance on your site for Changesets? |
Good question. I don't think we have anything yet. Do you have a specific question about them? 💭 |
Well, a few problems 🤯 When I apply a changeset for an on-the-fly validation (phx-change) with a multiple input form, the error span position is difficult to position. But worse, I don't understand how this works when you then do a phx-submit with an invalidated form. I do something liike def handle_event("up_date", %{"new_event" => %{"event_date" => date}} = _params, socket) do
changeset = NewEvent.changeset(%NewEvent{}, %{"event_date" => date})
%{user_id: user_id, place: place} = socket.assigns
case changeset.valid? do
true ->
:ok = async_create_event(%{...})
{:noreply, socket}
false ->
{:error, changeset} = Ecto.Changeset.apply_action(changeset, :insert)
# changeset = Map.put(changeset, :action, :insert)
{:noreply, assign(socket, :changeset, changeset)}
end
end |
https:/ndrean/live_map/blob/main/lib/live_map_web/live/forms/new_event.ex is my repo, my first little Elixir app🔥 |
@ndrean looks like a super interesting project. ⭐ |
Humm, no tests, no writings... awful I know but I also have to learn how to write tests!! ..... I have some notes prepared indeed to explain and remember what I did😁, I will put it in the Readme, you are right. The best is to run the app! Right now, this "changeset" problem drives me mad😤 |
Only an insanely curious and time-rich person will run an Anyway ... going to try and use your recommended script to create an |
Yes! this badges GitHub Workflow Status too!!! So many things to learn but that's the goal isn't it? |
Added an embryo of explanations/notes in the Readme🥳, then tests, then github flows |
Bug found / fixed !!! 🙏. It stupidly put (as an experiment but hey why not) the attribute First invalid submit returns nicely: When I submit twice an invalid form, Phoenix decides to put -> 🪳 Morality: get rid of |
Instructions pertinent to the OP of this issue:
{:ecto_erd, "~> 0.5", only: :dev},
mix deps.get
mix ecto.gen.erd --output-path=ecto_erd.mmd See: https://hexdocs.pm/ecto_erd/Mix.Tasks.Ecto.Gen.Erd.html for docs. |
erDiagram
apikeys {
integer id PK
bytea client_secret
bytea client_id
integer person_id
integer status
integer app_id
timestamp inserted_at
timestamp updated_at
}
apps {
integer id PK
bytea desc
timestamp end
bytea name
bytea url
integer person_id
integer status
timestamp inserted_at
timestamp updated_at
}
logs {
integer id PK
integer app_id
varchar auth_provider
bytea email
varchar msg
integer person_id
bytea request_path
integer status_id
integer user_agent_id
timestamp inserted_at
timestamp updated_at
}
people_roles {
integer id PK
integer app_id
integer person_id
integer role_id
integer granter_id
timestamp revoked
integer revoker_id
timestamp inserted_at
timestamp updated_at
}
permissions {
integer id PK
varchar desc
varchar name
integer person_id
timestamp inserted_at
timestamp updated_at
}
people {
integer id PK
varchar auth_provider
bytea email
bytea email_hash
bytea familyName
bytea givenName
varchar locale
bytea password_hash
bytea picture
bytea username
bytea username_hash
integer status
integer tag
integer key_id
integer app_id
integer github_id
timestamp inserted_at
timestamp updated_at
}
roles {
integer id PK
varchar desc
varchar name
integer person_id
integer app_id
timestamp inserted_at
timestamp updated_at
}
sessions {
integer id PK
integer app_id
varchar auth_provider
timestamp end
integer person_id
integer user_agent_id
timestamp inserted_at
timestamp updated_at
}
status {
integer id PK
varchar text
varchar desc
integer person_id
timestamp inserted_at
timestamp updated_at
}
user_agents {
integer id PK
varchar name
bytea ip_address
bytea ip_address_hash
}
schema_migrations {
integer version
timestamp inserted_at
}
apps ||--|{ apikeys : ""
apps ||--|{ people_roles : ""
people ||--|{ people_roles : ""
people ||--|{ status : ""
roles ||--|{ people_roles : ""
|
Can you make two pages? the 5 orphans and the other one with your triple joint table plus 2 tables 1<n. Authentication is hell!! |
Yeah, Need to fully document our initial implementation of |
My two cents. What is the usage of the "apps" table where you declare an "owner" (I imagine) with its apikeys in this context? Did you implement an RBAC? |
@ndrean mega appreciate your feedback on |
Do you really want to manage passwords? Don't you think that a passwordless process with a magic link should be the way to go? and then just produce a JWT or a session header for authorisation? |
@ndrean we prioritise "social" (OAuth) login on https://auth.dwyl.com Again, very much appreciate your feedback: https:/dwyl/auth/issues 🙏 |
The last identity login should just be passwordless I believe |
I also wanted to implement the Facebook login, but it seems hell to do server-side, whilst you also need HTTPS to use their snippet🤯 |
For clarity: I despise passwords and they are widely regarded as inferior security. Anyway ... back to the topic ERDs ... Going to stick with doing it manually for now as none of the auto-generation tools produce a good-looking image. 🙄 dwyl/auth#153 (comment) |
You are absolutely right about phising... but the user is warned, it is not a surprise for him. The only experience I had with passwords was just horrible. |
https://dev.to/sualeh/how-to-generate-mermaid-diagrams-for-your-database-33bn 👀
Appears to require running a python script ... 💭
Really wish there was automatic
SQL
import that would generate validMermaid
... 🙏This looks promising: https:/KarnerTh/mermerd and under active development. 🤞
Todo
Mermaid
for the Schema on GitHub CI after theElixir/Phoenix
tests are complete.Mermaid
either to GitHub via automated PR or S3 if that proves too difficultThe text was updated successfully, but these errors were encountered: