#| SQLite has a built-in schema table where you can do a level of introspection on the database. I've used this functionality a few times now so this encapsulates that behavior. |# (in-package #:cl-deck-builder2.models.sqlite-schema) ;; https://www.sqlite.org/schematab.html (defclass sqlite-schema () ((type :col-type :text) (name :col-type :text) (tbl-name :col-type :text) (rootpage :col-type :integer) (sql :col-type :text)) (:auto-pk nil) (:record-timestamps nil) (:metaclass mito:dao-table-mixin)) (defgeneric kind-of (obj) (:method ((sqlite-schema sqlite-schema)) (slot-value sqlite-schema 'type))) (defmethod name-of ((sqlite-schema sqlite-schema)) (slot-value sqlite-schema 'name)) (defgeneric rootpage-of (obj) (:method ((sqlite-schema sqlite-schema)) (slot-value sqlite-schema 'rootpage))) (defgeneric sql-of (obj) (:method ((sqlite-schema sqlite-schema)) (slot-value sqlite-schema 'sql))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun table-names () (mapcar #'name-of (select-dao 'sqlite-schema)))