Commit graph

2 commits

Author SHA1 Message Date
Gergő Tisza
ef338f3d56
db: Allow describing table creation via abstract schema change
Allow the 'before' field of an abstract schema change to be empty,
to describe a schema change that adds a new schema.

Merge the SQL logic, as generateSchemaChangeSql.php did not have
any cleanup for CREATE commands. Make some replacements simpler
and/or more robust. There are some other minor functional changes:
some double spaces are replaced by single spaces, ALTER is
formatted more nicely.

Change-Id: Ib2f60b492ced8ffe7bd6119f590c81f6a0ea9282
2023-10-10 20:06:53 -07:00
mainframe98
de0c4819d1 Add validation for abstract schema
This adds an option to the schema generating maintenance scripts to
validate abstract schemas and schema changes and a structure test to
validate exisiting schemas and schema changes. Schemas are also
validated when generating.

The validation for the schema doesn't impose limits on table, index or
column names as I couldn't find any reliable conventions for them.

The structure tests only cover MediaWiki itself as there is no
convention on where extensions store their abstract schema.
Ideally, auto detection would be possible for sql/, but for now
extensions have to define their own (thankfully trivial) tests.

A couple of invalid definitions were fixed thanks to these tests.

I aimed to be thorough, but not all parts of the abstract schema
are completely clear, and Doctrine's documentation is not complete.
As a result, not everything has a description field.

Bug: T298320
Change-Id: I681d265317d4d1584869142ebb23d4098c06885f
2022-02-22 17:41:08 +00:00