CREATE VIEW console_information_schema_table AS
SELECT
tbl.name AS table_name,
col.name AS column_name,
col.type AS data_type,
CASE WHEN col.pk = 1 THEN 'Yes' ELSE 'No' END AS is_primary_key,
CASE WHEN col."notnull" = 1 THEN 'Yes' ELSE 'No' END AS is_not_null,
col.dflt_value AS default_value,
'console/info-schema/table.sql?name=' || tbl.name || '&stats=yes' as info_schema_web_ui_path,
'[Content](console/info-schema/table.sql?name=' || tbl.name || '&stats=yes)' as info_schema_link_abbrev_md,
'[' || tbl.name || ' (table) Schema](console/info-schema/table.sql?name=' || tbl.name || '&stats=yes)' as info_schema_link_full_md,
'console/content/table/' || tbl.name || '.sql?stats=yes' as content_web_ui_path,
'[Content]($SITE_PREFIX_URL/console/content/table/' || tbl.name || '.sql?stats=yes)' as content_web_ui_link_abbrev_md,
'[' || tbl.name || ' (table) Content](console/content/table/' || tbl.name || '.sql?stats=yes)' as content_web_ui_link_full_md,
tbl.sql as sql_ddl
FROM sqlite_master tbl
JOIN pragma_table_info(tbl.name) col
WHERE tbl.type = 'table' AND tbl.name NOT LIKE 'sqlite_%'