diff options
author | Daimona Eaytoy <daimona.wiki@gmail.com> | 2024-12-12 22:57:31 +0100 |
---|---|---|
committer | Daimona Eaytoy <daimona.wiki@gmail.com> | 2024-12-13 03:12:56 +0100 |
commit | 251f4395865f8a33bcf32c6faa11748a14753492 (patch) | |
tree | 951d03a3860e9e1851cfe8e3c1ee8ea0c4217c29 /sql/postgres/patch-block_target.sql | |
parent | 589f6d5a40d7bf65250f174be1318a077733c5f5 (diff) | |
download | mediawikicore-251f4395865f8a33bcf32c6faa11748a14753492.tar.gz mediawikicore-251f4395865f8a33bcf32c6faa11748a14753492.zip |
Move SQL schema and schema changes to new sql/ top-level directory
This is the standard in every extension. DB schema changes are not
maintenance scripts, and therefore there's no apparent reason to have
the two things together, besides historical reasons.
Also, put each DB type in a separate directory, which wasn't the case
for MySQL before. For SQLite and Postgres schema changes, we now
follow the convention (used everywhere else, including the
generateSchemaChangeSql script) of having the DB type as the last part
of the path. This lets us generate schema changes for all DB types at
once, and without specifying the full file path.
Most files are just being renamed, the exceptions being to update
references to the old location (sometimes still referencing tables.sql).
Note that the old path is still referenced in the autogenerated comment
of schema changes SQL files. These will be regenerated in another
commit. Instead, the schema files are done now, because they're covered
by DatabaseIntegrationTest that would otherwise fail.
Bug: T382030
Change-Id: I3b4a614366d0bc629523ac40ce97d001f3b6bcf8
Diffstat (limited to 'sql/postgres/patch-block_target.sql')
-rw-r--r-- | sql/postgres/patch-block_target.sql | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/sql/postgres/patch-block_target.sql b/sql/postgres/patch-block_target.sql new file mode 100644 index 000000000000..00309e4371af --- /dev/null +++ b/sql/postgres/patch-block_target.sql @@ -0,0 +1,48 @@ + +CREATE TABLE block ( + bl_id SERIAL NOT NULL, + bl_target INT NOT NULL, + bl_by_actor BIGINT NOT NULL, + bl_reason_id BIGINT NOT NULL, + bl_timestamp TIMESTAMPTZ NOT NULL, + bl_anon_only SMALLINT DEFAULT 0 NOT NULL, + bl_create_account SMALLINT DEFAULT 1 NOT NULL, + bl_enable_autoblock SMALLINT DEFAULT 1 NOT NULL, + bl_expiry TIMESTAMPTZ NOT NULL, + bl_deleted SMALLINT DEFAULT 0 NOT NULL, + bl_block_email SMALLINT DEFAULT 0 NOT NULL, + bl_allow_usertalk SMALLINT DEFAULT 0 NOT NULL, + bl_parent_block_id INT DEFAULT NULL, + bl_sitewide SMALLINT DEFAULT 1 NOT NULL, + PRIMARY KEY(bl_id) +); + +CREATE INDEX bl_timestamp ON block (bl_timestamp); + +CREATE INDEX bl_target ON block (bl_target); + +CREATE INDEX bl_expiry ON block (bl_expiry); + +CREATE INDEX bl_parent_block_id ON block (bl_parent_block_id); + + +CREATE TABLE block_target ( + bt_id SERIAL NOT NULL, + bt_address TEXT DEFAULT NULL, + bt_user INT DEFAULT NULL, + bt_user_text TEXT DEFAULT NULL, + bt_auto SMALLINT DEFAULT 0 NOT NULL, + bt_range_start TEXT DEFAULT NULL, + bt_range_end TEXT DEFAULT NULL, + bt_ip_hex TEXT DEFAULT NULL, + bt_count INT DEFAULT 0 NOT NULL, + PRIMARY KEY(bt_id) +); + +CREATE INDEX bt_address ON block_target (bt_address); + +CREATE INDEX bt_ip_user_text ON block_target (bt_ip_hex, bt_user_text); + +CREATE INDEX bt_range ON block_target (bt_range_start, bt_range_end); + +CREATE INDEX bt_user ON block_target (bt_user); |