Skip to content

Adapt crud-admin-generator to work using PostgreSQL#122

Open
bepetersn wants to merge 3 commits intojonseg:masterfrom
bepetersn:psql
Open

Adapt crud-admin-generator to work using PostgreSQL#122
bepetersn wants to merge 3 commits intojonseg:masterfrom
bepetersn:psql

Conversation

@bepetersn
Copy link

@bepetersn bepetersn commented Jun 6, 2019

I don't know if someone will find this useful, but it seems possible because I needed it. This breaks support for MySQL and I'm not making an attempt to fix that, so please don't consider this an actual pull request as I don't want to break your library. Rather, I hope this helps someone. If you wanted to try to incorporate it, I think it could be manageable. Thanks for doing the work you did on this.

In order to query the columns from each table it was convenient for me to construct a VIEW to make the query a little shorter. Here's how I defined that view:

CREATE VIEW table_column_constraints as (SELECT c.table_schema, c.table_name, c.column_name
, c.data_type
, c.is_nullable
, tc.constraint_type
, c.column_default
FROM information_schema.columns AS c
LEFT JOIN information_schema.constraint_column_usage AS ccu USING (column_name, table_name)
LEFT JOIN information_schema.table_constraints tc ON tc.constraint_name=ccu.constraint_name WHERE c.table_schema='public');

NOTE: I haven't taken the time to get bulk downloads working. Not sure what is wrong. Everything else appears to be working as a baseline. There are also some ephemeral errors on update which I haven't fixed because they only flash on-screen before disappearing and the update succeeding.

@bepetersn
Copy link
Author

For others, calling it postgres, pgsql as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant