Commit graph

22 commits

Author SHA1 Message Date
Ammarpad
c397868e3d Remove custom table options from 'revision' table
This is not useful anymore.

Follow-up: Ia07dd52e43123473a1728523a3f863280537db8e
Change-Id: Ib903c69e3e331e96783c78b2ec0ab32e05f7f0d5
2021-05-23 21:57:04 +01:00
Ammarpad
5954b380fc Migrate revision table to abstract schema
Postgres:
 - Drop foreign key from rev_page
 - Make rev_page not nullable
 - Change rev_comment_id from int to bigint
 - Change rev_actor from int to bigint
 - Sync rev_page_id index with MySQL

MySQL/SQlite:
 - Drop default from rev_timestamp

Additional changes in the generator script to handle more
formatting issues due to use of additional custom table options

Bug: T230428
Bug: T164898
Change-Id: Ia07dd52e43123473a1728523a3f863280537db8e
2021-05-20 14:52:15 -07:00
Ammarpad
e497482ee4 DoctrineSchemaBuilder: Do not add prefix placeholder for Postgres at all
Adding it (only to be removed later) is not useful and interferes with
the internals of the schema builder because it masks the actual table
name during the table sql building and at some stages, this actual name
is required to be known

Bug: T191231
Change-Id: I57cc9b83c81f5c2d0d50c7b9e0dc334e7251c74f
2021-04-06 00:23:14 +00:00
Ammarpad
ffff04b375 Abstract schema: Handle MySQL Float/Double precision types
Subclass DBAL\Platforms\MySqlPlatform so that we can override
methods cleanly. Move the current MySQL hack from the schema
generator script to this class.

If 'float' is specified in the json spec without any option, the
FLOAT data type will be used. To use DOUBLE PRECISION (aka REAL)
a 'doublePrecision' option has to be specified and set to true.
No support for specifying arbitrary precision since no current
table is using that and the feature is deprecated in MySQL 8 anyway

Due to T270740, the subclassing is not straightforward because
the base DBAL MySqlPlatform class is renamed in DBAL 3.0.0. For
now a compatibility intermediate class is used as in PG subclass

Other changes: Use switch instead of if/else and remove brackets
in instantiating a class without arguments.

Bug: T191231
Change-Id: I9a5087b1e2afc2b63e30d67ea2ca616f047a0258
2021-03-21 05:00:55 +00:00
Reedy
f51d5071d6 Use .= instead of = . ....
Change-Id: If6c19795c6715d9818b8a946e560f3dee7aec0ff
2021-02-19 23:05:36 +00:00
jenkins-bot
8b0df31731 Merge "generateSchemaSql.php: Trim $IP/extensions/ from $relativeJsonPath" 2020-12-05 02:28:12 +00:00
jenkins-bot
ea77501778 Merge "Fix strange formatting issues in Postgres schema sql" 2020-11-26 21:33:54 +00:00
Ammar Abdulhamid
b922a292c9 Fix strange formatting issues in Postgres schema sql
Mere presence of partial index's WHERE clause is disrupting anything
that comes after it leading to strange and non-uniform formatting

Change-Id: I068113b3026d6c3422348e86b3048234b905bb1d
2020-11-24 11:47:18 +01:00
Reedy
49608e475c generateSchemaSql.php: Trim $IP/extensions/ from $relativeJsonPath
Change-Id: I4d45bfc9868268f64f7e4a5700143a36858a91d2
2020-11-24 03:57:13 +00:00
Reedy
a93f7efc05 generateSchemaSql.php: Handle invalid json files
Change-Id: I445da0a53e3883b853510338ba4061eb03510fa5
2020-11-24 02:39:10 +00:00
Ammar Abdulhamid
40ebc05ce4 Migrate job to abstract schema
Postgres:
 - Drop deafault from job_id
 - Add default to job_cmd
 - Change job_namespace datatype to INTEGER
 - Drop  job_cmd_namespace_title index
 - Add job_cmd index on the same fields as MySQL
 - Rename index job_timestamp_idx

MySQL:
 - Change job_title datatype to VARBINARY
 - Change job_timestamp datatype to BINARY (mwtimestamp)
 - Change job_token_timestamp datatype to BINARY (mwtimestamp)

Bug: T230428
Bug: T164898
Bug: T42626
Change-Id: I207aefc48c7bcbb5b5362af4b63d9a1383019a6d
2020-11-21 23:38:28 +01:00
Ammar Abdulhamid
b9717c8bf8 Migrate page_props to abstract schema
For Postges:
 - Drop foreign key from 'pp_page'
 - Move pk addition from the SQL file to the Updater class
 - Override default SQL value for float to return FLOAT which is in use.

For MySQL:
 - Override default SQL value for float to return FLOAT which is in use
 Hack added in generateSchemaSql.php

Bug: T230428
Bug: T164898
Change-Id: I3c591c9b8f43647b0208690bca79f2d0dd206922
2020-11-18 06:20:32 +01:00
Lucas Werkmeister
8b7a192fd3 Add extra blank line between tables in generated schemas
Put a single blank line between a CREATE TABLE and each accompanying
CREATE INDEX, but two blank lines between those statements and the next
CREATE TABLE.

Change-Id: I8ae8a3c808a772a338e968213031d390bf1b31ca
2020-08-20 12:04:57 +02:00
Lucas Werkmeister
639bd2178e Make newlines in generated schemas more consistent
Previously, a first str_replace() would add a single newline before any
CREATE (TABLE or INDEX), and then a second one would add another newline
after the $wgDBTableOptions, resulting in a blank line between any two
CREATEs and also a newline at the end of the file – at least for MySQL
schemas. But PostgreSQL and SQLite schemas don’t use $wgDBTableOptions,
so the second str_replace() was a no-op for them, and they got no blank
line between CREATEs nor a newline at the end of the file. Fix this by
making the first str_replace() insert two newlines and appending a final
newline all the time.

Bug: T260779
Change-Id: Idcc4fae76d382b559f21234f8a6f49e537a60f11
2020-08-19 16:54:41 +02:00
Amir Sarabadani
5f03e0b5af Migrate actor and user_former_groups tables to abstract schema
Also during the abstraction, fixing the schema drift between MySQL
and Postgres in these two tables by removing foreign key, sequences,
and changing data types (as outlined in T164898)

Bug: T230428
Bug: T164898
Change-Id: If737a746629511b5a53d7ae70328fd558bd58d0e
2020-07-12 19:19:54 +02:00
Amir Sarabadani
27244468d6 Make schema builder remove table prefixes from Postgres
Currently, Postgres just ignores the table prefix and in order to avoid
breaking existing installations, we remove them for now until we find a
better solution.

The documentation explicitly says that setting $wgDBprefix wouldn't
work on Postgres. And the current manual schema doesn't have it at all.

Bug: T230428
Change-Id: Ic6a3469ea3893b0166f108f2252f63827bfaaccb
2020-06-14 16:25:03 +02:00
Amir Sarabadani
bfe636bb18 Add test to compare generated sql with the abstract schema
This helps preventing mistakes, for example if you don't know or you
forget to generate the sql schema for one or all of them.
Also it helps preventing malicious changes to the generated files that
might go in without much scrutiny as the manual files.

Bug: T252919
Change-Id: I50e2715a55914f7712f9925c149bd09e8265a20b
2020-05-16 19:57:54 +02:00
Amir Sarabadani
8d011de416 More work on formatting generated sql
Bug: T230428
Change-Id: I2cb4cab045addd8f532f414923ce323e1bed52f2
2020-05-10 03:22:24 +02:00
Amir Sarabadani
11f241589b Wire empty abstract schema into installer
For more information on schema changes see:
https://www.mediawiki.org/wiki/Manual:Schema_changes

Bug: T191231
Bug: T230428
Change-Id: I779b9c61e388e998738a2ed41b0b8e2afdecd232
2020-05-09 20:42:11 +02:00
Reedy
a69d817523 Add doctrine/sql-formatter to pretty print generated SQL files
Bug: T191231
Change-Id: I727c3f37fb9d8f65eccc84cf95922cb6c5c2747f
2020-05-09 15:09:58 +00:00
Amir Sarabadani
dbbb3af6dc Small improvements to DoctrineSchemaBuilder and generateSchemaSql
Adding scope to const, adding docstring, adding comments to generated
files, fix default path.

Bug: T230428
Change-Id: I955a446421ffe5c8fa42aeedc0f962230e92e02a
2020-05-09 16:08:44 +02:00
Amir Sarabadani
8a4c400412 Introduce maintenance/generateSchemaSql.php
A new script to generate SQL schema from abstract json files.

Bug: T230421
Change-Id: I52f36ed40fc8aac6ff44f046169ae59dbb8f888a
2020-05-04 23:23:19 +00:00