egze
StructureSqlFormatter - clean away all the unnecessary output in structure.sql every time you run mix format
Hi everyone,
I wrote a small formatter to make diffs of structure.sql for postgres more readable.
Context: I’m a fan of committing structure.sql together with the pull request. If working with a team, there are sometimes merge conflicts, and in general it can be hard to read the changes for reviewers. The formatter aims to fix it and produce a more clean file.
It removes all the unneeded things, for example the lines with specific postgres version (because developers often have different versions)
Example:
--- Dumped from database version 14.5
--- Dumped by pg_dump version 16.1
Or removes unneeded comments:
Before:
--
-- Name: public; Type: SCHEMA; Schema: -; Owner: -
--
After
-- Name: public; Type: SCHEMA
Also it changes the lines with the list of applied migrations:
-
-INSERT INTO public."schema_migrations" (version) VALUES (20231213193252);
-INSERT INTO public."schema_migrations" (version) VALUES (20231213194556);
-INSERT INTO public."schema_migrations" (version) VALUES (20231213205552);
-INSERT INTO public."schema_migrations" (version) VALUES (20231214132216);
-INSERT INTO public."schema_migrations" (version) VALUES (20231214162040);
-INSERT INTO public."schema_migrations" (version) VALUES (20231214165232);
+
+INSERT INTO public."schema_migrations" (version) VALUES
+ (20231213193252)
+,(20231213194556)
+,(20231213205552)
+,(20231214132216)
+,(20231214162040)
+,(20231214165232)
+;
Then for each migration there will only be a diff of 1 added line.
All options are configurable too!
It is inspired by lfittl/activerecord-clean-db-structure, I mostly reimplemented the regexpes in Elixir and changed some small things here and there.
Most Liked
dimitarvp
Popular in Announcing
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #hex
- #security









