db-schema

Documents the exact MariaDB schema of the Toollab Laravel application including tables, constraints, and known inconsistencies.

Updated May 5, 2025
One-click install
npx skills add https://github.com/sebauvray/toollab-api --skill db-schema-sebauvray
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: db-schema
Source: https://github.com/sebauvray/toollab-api/tree/main/.claude/skills/db-schema
Command: npx skills add https://github.com/sebauvray/toollab-api --skill db-schema-sebauvray

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing queries, migrations, or Eloquent code against a database you only half-know leads to runtime errors, broken foreign keys, and wrong assumptions about which columns actually exist. This Skill provides the verified, post-migration state of the Toollab MariaDB schema so you never guess at a column name, constraint, or cascade behavior again. ## Core Features & Use Cases - Complete table reference: Every business table (schools, users, user_roles, classrooms, student_classrooms, attendances, paiements, lignes_paiement, etc.) with columns, types, unique constraints, indexes, and foreign key behaviors. - Known inconsistencies documented: Mismatches between $fillable and real columns, missing indexes that hurt performance, RESTRICT vs CASCADE vs SET NULL behaviors when deleting a User, and migration bugs (e.g., a wrong table name in a down() method). - Schema inspection commands: Ready-to-run docker/artisan/mysql commands to verify the live schema. - Use Case: Before writing a migration that adds a column to student_classrooms, check this Skill to learn that updated_by does not exist on that table even though the model's TrackChangesTrait tries to set it. ## Quick Start Ask the AI to check the db-schema reference before writing a query or migration against the Toollab database, for example to verify whether a column exists on a given table.

Frequently Asked Questions about db-schema

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I check the real database schema before writing a Laravel migration?▼

Consult the schema reference to see the exact post-migration state of every table, then verify live with php artisan tinker using Schema::getColumnListing or SHOW CREATE TABLE via the mysql client in the docker container.

What happens when I delete a User in a Laravel app with foreign keys?▼

It depends on each foreign key: user_roles.user_id, paiements.created_by, and class_schedules.teacher_id are RESTRICT and block deletion with SQL error 23000, while user_infos, student_classrooms, and attendances cascade, and comments.user_id is set null.

Why does deleting a user throw SQL error 23000?▼

Error 23000 is a foreign key constraint violation. Since nearly every user has at least one user_roles row and that column is RESTRICT, a bare delete() fails; you must purge user_infos and user_roles first, as FamilyController::deleteStudent does.

Which missing database indexes hurt query performance the most?▼

Two composite indexes are missing: user_roles(roleable_type, roleable_id), needed by the polymorphic batch queries used across payment and family features, and user_infos(user_id, key), which is queried constantly for attributes like birthdate.

Does the Toollab database use soft deletes?▼

No. No table has a deleted_at column, so every DELETE is permanent and cascades according to its foreign key definitions. There are also no separate students or teachers tables; those are users with user_roles.