Skip to content
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

Introspection of MySQL views #17414

Closed
Tracked by #17412
pimeys opened this issue Jan 19, 2023 · 0 comments · Fixed by prisma/prisma-engines#3732
Closed
Tracked by #17412

Introspection of MySQL views #17414

pimeys opened this issue Jan 19, 2023 · 0 comments · Fixed by prisma/prisma-engines#3732

Comments

@pimeys
Copy link
Contributor

pimeys commented Jan 19, 2023

We should fit this beauty to the SQL describer:

select col.table_schema as database_name,
       col.table_name as view_name,
       col.ordinal_position,
       col.column_name,
       col.data_type,
       case when col.character_maximum_length is not null
            then col.character_maximum_length
            else col.numeric_precision end as max_length,
       col.is_nullable
from information_schema.columns col
join information_schema.views vie on vie.table_schema = col.table_schema
                                  and vie.table_name = col.table_name
where col.table_schema not in ('sys','information_schema',
                               'mysql', 'performance_schema')
    -- and vie.table_schema = 'database_name' -- put your database name here
order by col.table_schema,
         col.table_name,
         col.ordinal_position;

There can be relations between views, or models and views. These are not based on foreign keys. They should be kept in re-introspection, for now.

Part of: #17412

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

Successfully merging a pull request may close this issue.

2 participants