v1.7.0
This commit is contained in:
parent
98b1cf0f3b
commit
4402f3570d
20 changed files with 1683 additions and 382 deletions
|
|
@ -24,6 +24,7 @@ class Database {
|
|||
self::migration_100();
|
||||
self::migration_101();
|
||||
self::migration_110();
|
||||
self::migration_120();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -48,6 +49,10 @@ class Database {
|
|||
if ( version_compare( $current, '1.1.0', '<' ) ) {
|
||||
self::migration_110();
|
||||
}
|
||||
|
||||
if ( version_compare( $current, '1.2.0', '<' ) ) {
|
||||
self::migration_120();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -57,6 +62,7 @@ class Database {
|
|||
*/
|
||||
public static function drop_tables(): void {
|
||||
global $wpdb;
|
||||
$wpdb->query( "DROP TABLE IF EXISTS `{$wpdb->prefix}mra_dismissed_alerts`" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery
|
||||
$wpdb->query( "DROP TABLE IF EXISTS `{$wpdb->prefix}mra_provider_status`" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery
|
||||
$wpdb->query( "DROP TABLE IF EXISTS `{$wpdb->prefix}mra_external_results`" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery
|
||||
$wpdb->query( "DROP TABLE IF EXISTS `{$wpdb->prefix}mra_media_usage`" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery
|
||||
|
|
@ -74,6 +80,7 @@ class Database {
|
|||
global $wpdb;
|
||||
|
||||
// phpcs:disable WordPress.DB.DirectDatabaseQuery
|
||||
$wpdb->query( "TRUNCATE TABLE `{$wpdb->prefix}mra_dismissed_alerts`" );
|
||||
$wpdb->query( "TRUNCATE TABLE `{$wpdb->prefix}mra_provider_status`" );
|
||||
$wpdb->query( "TRUNCATE TABLE `{$wpdb->prefix}mra_external_results`" );
|
||||
$wpdb->query( "TRUNCATE TABLE `{$wpdb->prefix}mra_media_usage`" );
|
||||
|
|
@ -215,4 +222,32 @@ class Database {
|
|||
);
|
||||
// phpcs:enable WordPress.DB.DirectDatabaseQuery,WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||
}
|
||||
|
||||
/**
|
||||
* Migration 1.2.0 — creates the mra_dismissed_alerts table.
|
||||
*
|
||||
* Stores per-attachment alert dismissal records with dismisser, timestamp,
|
||||
* and optional notes. Primary key on attachment_id (one dismissal per image).
|
||||
*
|
||||
* Safe to re-run: dbDelta skips existing tables.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private static function migration_120(): void {
|
||||
global $wpdb;
|
||||
|
||||
$charset_collate = $wpdb->get_charset_collate();
|
||||
|
||||
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
||||
|
||||
dbDelta(
|
||||
"CREATE TABLE {$wpdb->prefix}mra_dismissed_alerts (
|
||||
attachment_id bigint(20) unsigned NOT NULL,
|
||||
dismissed_by bigint(20) unsigned NOT NULL DEFAULT 0,
|
||||
dismissed_at datetime NOT NULL,
|
||||
notes text NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (attachment_id)
|
||||
) {$charset_collate};"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue