diff --git a/CHANGELOG.md b/CHANGELOG.md index 38d36ca..119738d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ All notable changes are documented here. This project follows Keep a Changelog a ## [Unreleased] ### Added +- `createDate` and `modifyDate` on every table (date-time, not editable, QQQ create-date and modify-date behaviors), with append-only changesets 35 to 51 that add the missing columns (nullable, default current time) and fill existing rows. See UPGRADE.md. - H2 2.x support (`H2StatsProvider`) from `INFORMATION_SCHEMA`: statement statistics from `QUERY_STATISTICS` (when the database runs with `QUERY_STATISTICS=TRUE`), sessions with blocking and idle-in-transaction detection, connection counts, table row estimates and sizes, index definitions, settings, and text query plans (`EXPLAIN`; `EXPLAIN ANALYZE` only for non-admin H2 users, since H2 has no read-only transaction: plans refuse side-effecting functions such as `FILE_WRITE`, DDL/DML keywords, user-defined aliases and multiple statements). The enterprise test server showed UNSUPPORTED on H2; it now collects. - Per-area capabilities (`StatsFeature`): providers declare which statistics areas they can supply and `ProviderCapabilities.features()` reports what is available on a connection. Snapshot cache-hit ratio and connection limit stay empty when the vendor has none, and analysis rules declare the areas they need (`DbPerfRule.requires()`) and are skipped on providers that cannot supply them, so H2 never gets "unused index" or "low cache hit" findings from missing counters. - Provider registry keyed by JDBC product name (`DbStatsProviders.register`), with `docs/PROVIDERS.md` describing what MySQL/MariaDB and SQLite would map to. diff --git a/UPGRADE.md b/UPGRADE.md index 4b956e6..adf4072 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,101 @@ # Upgrading QBit DB Performance +## Created and Modified dates on every table + +Every table now has `createDate` and `modifyDate` (date-time, not editable, maintained by QQQ's create-date and modify-date field behaviors). The qbit writes all of its tables through QQQ's insert and update actions, so no write path sets them by hand. Hosts that include the shipped Liquibase changelog get the columns from changesets 35 to 51, which are append-only and idempotent (`ADD COLUMN IF NOT EXISTS`). + +Hosts with hand-written migrations run these PostgreSQL statements (one block per table) before deploying. The new columns are nullable with a default of the current time, so the previous release keeps working against the migrated database during a rolling deployment. On PostgreSQL 11 and newer, adding a column with a default that is not volatile does not rewrite the table. Existing rows get the capture time (`captured_at`, or `requested_at` for query plans) where the table has one, otherwise the time of the migration; rows that earlier releases left without dates in the tables that already had the columns are filled the same way. The `UPDATE` statements touch each existing row once; skip them on a very large table to leave the migration time as the date. + +Tables that gain both columns: `db_perf_query_snapshot`, `db_perf_table_snapshot`, `db_perf_activity_sample`, `db_perf_connection_sample`, `db_perf_explain`, `db_perf_query_daily`, `db_perf_table_daily`, `db_perf_attribution`, `db_perf_attribution_daily`, `db_perf_repeat_pattern`. `db_perf_snapshot` gains `modify_date`. Column names are `create_date` and `modify_date`; a host that does not derive snake_case backend names from field names uses `createDate` and `modifyDate`. + +```sql +-- qbit-db-performance, release line 0.1: Created and Modified dates on every table (PostgreSQL). + +-- Run BEFORE deploying this release. Safe while the previous release is still running: the new columns are nullable +-- with a default of the current time, so rows written by the previous release get both dates. On PostgreSQL 11 and +-- newer, ADD COLUMN with a default that is not volatile (CURRENT_TIMESTAMP is stable) does not rewrite the table; +-- it takes a brief ACCESS EXCLUSIVE lock, so run it off peak or with SET lock_timeout. The UPDATE statements that +-- follow touch each existing row once (row locks, WAL); skipping them leaves the migration time as the date. +-- Column names below assume snake_case backend names (create_date, modify_date). A host that does not derive +-- snake_case names from field names uses "createDate" and "modifyDate" instead: replace the two column names. +-- Every statement is idempotent. Run the file once, in one transaction per block if preferred. + +-- db_perf_query_snapshot +ALTER TABLE db_perf_query_snapshot ADD COLUMN IF NOT EXISTS create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE db_perf_query_snapshot ADD COLUMN IF NOT EXISTS modify_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +UPDATE db_perf_query_snapshot SET create_date = captured_at, modify_date = captured_at WHERE captured_at IS NOT NULL; + +-- db_perf_table_snapshot +ALTER TABLE db_perf_table_snapshot ADD COLUMN IF NOT EXISTS create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE db_perf_table_snapshot ADD COLUMN IF NOT EXISTS modify_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +UPDATE db_perf_table_snapshot SET create_date = captured_at, modify_date = captured_at WHERE captured_at IS NOT NULL; + +-- db_perf_activity_sample +ALTER TABLE db_perf_activity_sample ADD COLUMN IF NOT EXISTS create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE db_perf_activity_sample ADD COLUMN IF NOT EXISTS modify_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +UPDATE db_perf_activity_sample SET create_date = captured_at, modify_date = captured_at WHERE captured_at IS NOT NULL; + +-- db_perf_connection_sample +ALTER TABLE db_perf_connection_sample ADD COLUMN IF NOT EXISTS create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE db_perf_connection_sample ADD COLUMN IF NOT EXISTS modify_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +UPDATE db_perf_connection_sample SET create_date = captured_at, modify_date = captured_at WHERE captured_at IS NOT NULL; + +-- db_perf_explain +ALTER TABLE db_perf_explain ADD COLUMN IF NOT EXISTS create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE db_perf_explain ADD COLUMN IF NOT EXISTS modify_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +UPDATE db_perf_explain SET create_date = requested_at, modify_date = requested_at WHERE requested_at IS NOT NULL; + +-- db_perf_query_daily +ALTER TABLE db_perf_query_daily ADD COLUMN IF NOT EXISTS create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE db_perf_query_daily ADD COLUMN IF NOT EXISTS modify_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; + +-- db_perf_table_daily +ALTER TABLE db_perf_table_daily ADD COLUMN IF NOT EXISTS create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE db_perf_table_daily ADD COLUMN IF NOT EXISTS modify_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; + +-- db_perf_attribution +ALTER TABLE db_perf_attribution ADD COLUMN IF NOT EXISTS create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE db_perf_attribution ADD COLUMN IF NOT EXISTS modify_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; + +-- db_perf_attribution_daily +ALTER TABLE db_perf_attribution_daily ADD COLUMN IF NOT EXISTS create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE db_perf_attribution_daily ADD COLUMN IF NOT EXISTS modify_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; + +-- db_perf_repeat_pattern +ALTER TABLE db_perf_repeat_pattern ADD COLUMN IF NOT EXISTS create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE db_perf_repeat_pattern ADD COLUMN IF NOT EXISTS modify_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; + +-- db_perf_snapshot (create_date already exists) +ALTER TABLE db_perf_snapshot ADD COLUMN IF NOT EXISTS modify_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +UPDATE db_perf_snapshot SET create_date = captured_at WHERE create_date IS NULL; +UPDATE db_perf_snapshot SET modify_date = create_date WHERE create_date IS NOT NULL; + +-- Tables that already have both columns: fill rows an earlier release left empty. +-- db_perf_statement +UPDATE db_perf_statement SET create_date = COALESCE(first_seen_at, CURRENT_TIMESTAMP) WHERE create_date IS NULL; +UPDATE db_perf_statement SET modify_date = create_date WHERE modify_date IS NULL; + +-- db_perf_finding +UPDATE db_perf_finding SET create_date = COALESCE(first_seen_at, CURRENT_TIMESTAMP) WHERE create_date IS NULL; +UPDATE db_perf_finding SET modify_date = create_date WHERE modify_date IS NULL; + +-- db_perf_settings +UPDATE db_perf_settings SET create_date = CURRENT_TIMESTAMP WHERE create_date IS NULL; +UPDATE db_perf_settings SET modify_date = create_date WHERE modify_date IS NULL; + +-- db_perf_rule +UPDATE db_perf_rule SET create_date = CURRENT_TIMESTAMP WHERE create_date IS NULL; +UPDATE db_perf_rule SET modify_date = create_date WHERE modify_date IS NULL; + +-- db_perf_table_stat +UPDATE db_perf_table_stat SET create_date = CURRENT_TIMESTAMP WHERE create_date IS NULL; +UPDATE db_perf_table_stat SET modify_date = create_date WHERE modify_date IS NULL; + +-- db_perf_index_stat +UPDATE db_perf_index_stat SET create_date = CURRENT_TIMESTAMP WHERE create_date IS NULL; +UPDATE db_perf_index_stat SET modify_date = create_date WHERE modify_date IS NULL; +``` + ## First release There is no previous published release. See [CHANGELOG.md](CHANGELOG.md) for additions and [README.md](README.md) for complete installation. diff --git a/src/main/java/com/kingsrook/qbits/dbperformance/metadata/DbPerfMetaData.java b/src/main/java/com/kingsrook/qbits/dbperformance/metadata/DbPerfMetaData.java index f2ac119..ad86aa6 100644 --- a/src/main/java/com/kingsrook/qbits/dbperformance/metadata/DbPerfMetaData.java +++ b/src/main/java/com/kingsrook/qbits/dbperformance/metadata/DbPerfMetaData.java @@ -226,7 +226,7 @@ public final class DbPerfMetaData snapshot.withoutCapabilities(Capability.TABLE_INSERT, Capability.TABLE_UPDATE, Capability.TABLE_DELETE); snapshot.withSection(new QFieldSection("identity", new QIcon("table_rows"), Tier.T1, List.of("id", "backendName", "capturedAt", "intervalSeconds", "status", "durationMs", "errorMessage"))); snapshot.withSection(new QFieldSection("details", new QIcon("table_rows"), Tier.T2, List.of("statsResetDetected", "includesTables", "xactCommit", "xactRollback", "blksHit", "blksRead", "cacheHitRatio", "tempFiles", "tempBytes", "deadlocks", "conflicts", "connectionsTotal", "connectionsActive", "connectionsIdle", "connectionsIdleInTx", "maxConnections", "databaseSizeBytes", "statementCount", "statementCalls", "statementTotalMs", "storedStatementCount"))); - snapshot.withSection(new QFieldSection("system", new QIcon("table_rows"), Tier.T3, List.of("createDate", "rawXactCommit", "rawXactRollback", "rawBlksHit", "rawBlksRead", "rawTempFiles", "rawTempBytes", "rawDeadlocks", "rawConflicts", "rawStatsReset", "rawStatementStatsReset"))); + snapshot.withSection(new QFieldSection("system", new QIcon("table_rows"), Tier.T3, List.of("createDate", "modifyDate", "rawXactCommit", "rawXactRollback", "rawBlksHit", "rawBlksRead", "rawTempFiles", "rawTempBytes", "rawDeadlocks", "rawConflicts", "rawStatsReset", "rawStatementStatsReset"))); instance.addTable(snapshot); QTableMetaData statement = base(config, DbPerfStatement.TABLE_NAME, "Queries", DbPerfStatement.class); @@ -286,6 +286,7 @@ public final class DbPerfMetaData querySnapshot.withoutCapabilities(Capability.TABLE_INSERT, Capability.TABLE_UPDATE, Capability.TABLE_DELETE); querySnapshot.withSection(new QFieldSection("identity", new QIcon("table_rows"), Tier.T1, List.of("id", "snapshotId", "statementId", "capturedAt", "calls", "totalMs", "meanMs"))); querySnapshot.withSection(new QFieldSection("details", new QIcon("table_rows"), Tier.T2, List.of("maxMs", "rowsCount", "sharedBlksHit", "sharedBlksRead", "hitRatio", "tempBlksWritten", "shareOfDbTime"))); + querySnapshot.withSection(new QFieldSection("system", new QIcon("table_rows"), Tier.T3, List.of("createDate", "modifyDate"))); instance.addTable(querySnapshot); QTableMetaData queryDaily = base(config, DbPerfQueryDaily.TABLE_NAME, "Query Daily", DbPerfQueryDaily.class); @@ -306,6 +307,7 @@ public final class DbPerfMetaData queryDaily.withoutCapabilities(Capability.TABLE_INSERT, Capability.TABLE_UPDATE, Capability.TABLE_DELETE); queryDaily.withSection(new QFieldSection("identity", new QIcon("table_rows"), Tier.T1, List.of("id", "statementId", "day", "calls", "totalMs", "meanMs", "maxMs"))); queryDaily.withSection(new QFieldSection("details", new QIcon("table_rows"), Tier.T2, List.of("rowsCount", "hitRatio", "shareOfDbTime", "snapshots"))); + queryDaily.withSection(new QFieldSection("system", new QIcon("table_rows"), Tier.T3, List.of("createDate", "modifyDate"))); instance.addTable(queryDaily); QTableMetaData tableStat = base(config, DbPerfTableStat.TABLE_NAME, "Tables", DbPerfTableStat.class); @@ -378,6 +380,7 @@ public final class DbPerfMetaData tableSnapshot.withoutCapabilities(Capability.TABLE_INSERT, Capability.TABLE_UPDATE, Capability.TABLE_DELETE); tableSnapshot.withSection(new QFieldSection("identity", new QIcon("table_rows"), Tier.T1, List.of("id", "snapshotId", "tableStatId", "capturedAt", "seqScan", "seqTupRead", "idxScan"))); tableSnapshot.withSection(new QFieldSection("details", new QIcon("table_rows"), Tier.T2, List.of("idxTupFetch", "nTupIns", "nTupUpd", "nTupDel", "nTupHotUpd", "nLiveTup", "nDeadTup", "totalBytes", "tableBytes", "indexBytes", "autovacuumCount", "autoanalyzeCount", "freezeAge"))); + tableSnapshot.withSection(new QFieldSection("system", new QIcon("table_rows"), Tier.T3, List.of("createDate", "modifyDate"))); instance.addTable(tableSnapshot); QTableMetaData tableDaily = base(config, DbPerfTableDaily.TABLE_NAME, "Table Daily", DbPerfTableDaily.class); @@ -399,6 +402,7 @@ public final class DbPerfMetaData tableDaily.withoutCapabilities(Capability.TABLE_INSERT, Capability.TABLE_UPDATE, Capability.TABLE_DELETE); tableDaily.withSection(new QFieldSection("identity", new QIcon("table_rows"), Tier.T1, List.of("id", "tableStatId", "day", "seqScan", "idxScan", "seqTupRead", "nTupIns"))); tableDaily.withSection(new QFieldSection("details", new QIcon("table_rows"), Tier.T2, List.of("nTupUpd", "nTupDel", "nLiveTup", "nDeadTup", "totalBytes"))); + tableDaily.withSection(new QFieldSection("system", new QIcon("table_rows"), Tier.T3, List.of("createDate", "modifyDate"))); instance.addTable(tableDaily); QTableMetaData indexStat = base(config, DbPerfIndexStat.TABLE_NAME, "Indexes", DbPerfIndexStat.class); @@ -464,6 +468,7 @@ public final class DbPerfMetaData activitySample.withoutCapabilities(Capability.TABLE_INSERT, Capability.TABLE_UPDATE, Capability.TABLE_DELETE); activitySample.withSection(new QFieldSection("identity", new QIcon("table_rows"), Tier.T1, List.of("id", "snapshotId", "capturedAt", "pid", "dbUser", "applicationName", "clientAddr"))); activitySample.withSection(new QFieldSection("details", new QIcon("table_rows"), Tier.T2, List.of("state", "waitEventType", "waitEvent", "backendType", "xactStart", "queryStart", "stateChange", "querySeconds", "xactSeconds", "blockedBy", "blockingCount", "reason", "queryId", "statementId", "queryFingerprint", "queryTextNormalized"))); + activitySample.withSection(new QFieldSection("system", new QIcon("table_rows"), Tier.T3, List.of("createDate", "modifyDate"))); instance.addTable(activitySample); QTableMetaData connectionSample = base(config, DbPerfConnectionSample.TABLE_NAME, "Connection Samples", DbPerfConnectionSample.class); @@ -479,6 +484,7 @@ public final class DbPerfMetaData connectionSample.getField("connectionCount").setBackendName("connection_count"); connectionSample.withoutCapabilities(Capability.TABLE_INSERT, Capability.TABLE_UPDATE, Capability.TABLE_DELETE); connectionSample.withSection(new QFieldSection("identity", new QIcon("table_rows"), Tier.T1, List.of("id", "snapshotId", "capturedAt", "dbUser", "applicationName", "state", "connectionCount"))); + connectionSample.withSection(new QFieldSection("system", new QIcon("table_rows"), Tier.T3, List.of("createDate", "modifyDate"))); instance.addTable(connectionSample); QTableMetaData attribution = base(config, DbPerfAttribution.TABLE_NAME, "QQQ Attribution", DbPerfAttribution.class); @@ -506,6 +512,7 @@ public final class DbPerfMetaData attribution.withoutCapabilities(Capability.TABLE_INSERT, Capability.TABLE_UPDATE, Capability.TABLE_DELETE); attribution.withSection(new QFieldSection("identity", new QIcon("table_rows"), Tier.T1, List.of("id", "windowStart", "windowEnd", "podName", "unitKind", "unitName", "processName"))); attribution.withSection(new QFieldSection("details", new QIcon("table_rows"), Tier.T2, List.of("tableName", "operation", "fingerprint", "sqlText", "units", "statements", "totalMs", "maxMs", "rowsCount", "errors", "sampleRate"))); + attribution.withSection(new QFieldSection("system", new QIcon("table_rows"), Tier.T3, List.of("createDate", "modifyDate"))); instance.addTable(attribution); QTableMetaData attributionDaily = base(config, DbPerfAttributionDaily.TABLE_NAME, "QQQ Attribution Daily", DbPerfAttributionDaily.class); @@ -532,6 +539,7 @@ public final class DbPerfMetaData attributionDaily.withoutCapabilities(Capability.TABLE_INSERT, Capability.TABLE_UPDATE, Capability.TABLE_DELETE); attributionDaily.withSection(new QFieldSection("identity", new QIcon("table_rows"), Tier.T1, List.of("id", "day", "rollupKey", "unitKind", "unitName", "processName", "tableName"))); attributionDaily.withSection(new QFieldSection("details", new QIcon("table_rows"), Tier.T2, List.of("operation", "fingerprint", "sqlText", "units", "statements", "totalMs", "maxMs", "rowsCount", "errors"))); + attributionDaily.withSection(new QFieldSection("system", new QIcon("table_rows"), Tier.T3, List.of("createDate", "modifyDate"))); instance.addTable(attributionDaily); QTableMetaData repeatPattern = base(config, DbPerfRepeatPattern.TABLE_NAME, "Repeated Statements", DbPerfRepeatPattern.class); @@ -554,6 +562,7 @@ public final class DbPerfMetaData repeatPattern.withoutCapabilities(Capability.TABLE_INSERT, Capability.TABLE_UPDATE, Capability.TABLE_DELETE); repeatPattern.withSection(new QFieldSection("identity", new QIcon("table_rows"), Tier.T1, List.of("id", "windowStart", "windowEnd", "podName", "unitKind", "unitName", "processName"))); repeatPattern.withSection(new QFieldSection("details", new QIcon("table_rows"), Tier.T2, List.of("tableName", "fingerprint", "sqlText", "unitsAffected", "maxRepeats", "totalRepeats", "sampleRate"))); + repeatPattern.withSection(new QFieldSection("system", new QIcon("table_rows"), Tier.T3, List.of("createDate", "modifyDate"))); instance.addTable(repeatPattern); QTableMetaData finding = base(config, DbPerfFinding.TABLE_NAME, "Findings", DbPerfFinding.class); @@ -627,6 +636,7 @@ public final class DbPerfMetaData explain.withoutCapabilities(Capability.TABLE_INSERT, Capability.TABLE_UPDATE, Capability.TABLE_DELETE); explain.withSection(new QFieldSection("identity", new QIcon("table_rows"), Tier.T1, List.of("id", "statementId", "requestedBy", "requestedAt", "mode", "sqlFingerprint", "sqlText"))); explain.withSection(new QFieldSection("details", new QIcon("table_rows"), Tier.T2, List.of("parameterCount", "durationMs", "outcome", "errorMessage", "planJson", "planText", "totalCost"))); + explain.withSection(new QFieldSection("system", new QIcon("table_rows"), Tier.T3, List.of("createDate", "modifyDate"))); instance.addTable(explain); instance.addPossibleValueSource(source("db_perf_Provider", DbPerfPossibleValues.Provider.values())); diff --git a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfActivitySample.java b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfActivitySample.java index 115e484..c412e5c 100644 --- a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfActivitySample.java +++ b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfActivitySample.java @@ -26,6 +26,7 @@ import java.time.Instant; import com.kingsrook.qqq.backend.core.model.data.QField; import com.kingsrook.qqq.backend.core.model.data.QRecord; import com.kingsrook.qqq.backend.core.model.data.QRecordEntity; +import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior; /******************************************************************************* @@ -104,6 +105,12 @@ public class DbPerfActivitySample extends QRecordEntity @QField(maxLength = 4000) private String queryTextNormalized; + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE) + private Instant createDate; + + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE) + private Instant modifyDate; + /******************************************************************************* ** Default constructor. @@ -764,4 +771,60 @@ public class DbPerfActivitySample extends QRecordEntity this.queryTextNormalized = queryTextNormalized; return (this); } + + + /******************************************************************************* + ** Getter for createDate. + *******************************************************************************/ + public Instant getCreateDate() + { + return (this.createDate); + } + + + /******************************************************************************* + ** Setter for createDate. + *******************************************************************************/ + public void setCreateDate(Instant createDate) + { + this.createDate = createDate; + } + + + /******************************************************************************* + ** Fluent setter for createDate. + *******************************************************************************/ + public DbPerfActivitySample withCreateDate(Instant createDate) + { + this.createDate = createDate; + return (this); + } + + + /******************************************************************************* + ** Getter for modifyDate. + *******************************************************************************/ + public Instant getModifyDate() + { + return (this.modifyDate); + } + + + /******************************************************************************* + ** Setter for modifyDate. + *******************************************************************************/ + public void setModifyDate(Instant modifyDate) + { + this.modifyDate = modifyDate; + } + + + /******************************************************************************* + ** Fluent setter for modifyDate. + *******************************************************************************/ + public DbPerfActivitySample withModifyDate(Instant modifyDate) + { + this.modifyDate = modifyDate; + return (this); + } } diff --git a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfAttribution.java b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfAttribution.java index 568b5d8..1bc1ce9 100644 --- a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfAttribution.java +++ b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfAttribution.java @@ -26,6 +26,7 @@ import java.time.Instant; import com.kingsrook.qqq.backend.core.model.data.QField; import com.kingsrook.qqq.backend.core.model.data.QRecord; import com.kingsrook.qqq.backend.core.model.data.QRecordEntity; +import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior; /******************************************************************************* @@ -89,6 +90,12 @@ public class DbPerfAttribution extends QRecordEntity @QField private BigDecimal sampleRate; + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE) + private Instant createDate; + + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE) + private Instant modifyDate; + /******************************************************************************* ** Default constructor. @@ -609,4 +616,60 @@ public class DbPerfAttribution extends QRecordEntity this.sampleRate = sampleRate; return (this); } + + + /******************************************************************************* + ** Getter for createDate. + *******************************************************************************/ + public Instant getCreateDate() + { + return (this.createDate); + } + + + /******************************************************************************* + ** Setter for createDate. + *******************************************************************************/ + public void setCreateDate(Instant createDate) + { + this.createDate = createDate; + } + + + /******************************************************************************* + ** Fluent setter for createDate. + *******************************************************************************/ + public DbPerfAttribution withCreateDate(Instant createDate) + { + this.createDate = createDate; + return (this); + } + + + /******************************************************************************* + ** Getter for modifyDate. + *******************************************************************************/ + public Instant getModifyDate() + { + return (this.modifyDate); + } + + + /******************************************************************************* + ** Setter for modifyDate. + *******************************************************************************/ + public void setModifyDate(Instant modifyDate) + { + this.modifyDate = modifyDate; + } + + + /******************************************************************************* + ** Fluent setter for modifyDate. + *******************************************************************************/ + public DbPerfAttribution withModifyDate(Instant modifyDate) + { + this.modifyDate = modifyDate; + return (this); + } } diff --git a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfAttributionDaily.java b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfAttributionDaily.java index bb50a54..c00f49b 100644 --- a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfAttributionDaily.java +++ b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfAttributionDaily.java @@ -22,10 +22,12 @@ package com.kingsrook.qbits.dbperformance.model; import java.math.BigDecimal; +import java.time.Instant; import java.time.LocalDate; import com.kingsrook.qqq.backend.core.model.data.QField; import com.kingsrook.qqq.backend.core.model.data.QRecord; import com.kingsrook.qqq.backend.core.model.data.QRecordEntity; +import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior; /******************************************************************************* @@ -83,6 +85,12 @@ public class DbPerfAttributionDaily extends QRecordEntity @QField private Long errors; + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE) + private Instant createDate; + + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE) + private Instant modifyDate; + /******************************************************************************* ** Default constructor. @@ -547,4 +555,60 @@ public class DbPerfAttributionDaily extends QRecordEntity this.errors = errors; return (this); } + + + /******************************************************************************* + ** Getter for createDate. + *******************************************************************************/ + public Instant getCreateDate() + { + return (this.createDate); + } + + + /******************************************************************************* + ** Setter for createDate. + *******************************************************************************/ + public void setCreateDate(Instant createDate) + { + this.createDate = createDate; + } + + + /******************************************************************************* + ** Fluent setter for createDate. + *******************************************************************************/ + public DbPerfAttributionDaily withCreateDate(Instant createDate) + { + this.createDate = createDate; + return (this); + } + + + /******************************************************************************* + ** Getter for modifyDate. + *******************************************************************************/ + public Instant getModifyDate() + { + return (this.modifyDate); + } + + + /******************************************************************************* + ** Setter for modifyDate. + *******************************************************************************/ + public void setModifyDate(Instant modifyDate) + { + this.modifyDate = modifyDate; + } + + + /******************************************************************************* + ** Fluent setter for modifyDate. + *******************************************************************************/ + public DbPerfAttributionDaily withModifyDate(Instant modifyDate) + { + this.modifyDate = modifyDate; + return (this); + } } diff --git a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfConnectionSample.java b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfConnectionSample.java index 0ebc34c..bacc6f1 100644 --- a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfConnectionSample.java +++ b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfConnectionSample.java @@ -25,6 +25,7 @@ import java.time.Instant; import com.kingsrook.qqq.backend.core.model.data.QField; import com.kingsrook.qqq.backend.core.model.data.QRecord; import com.kingsrook.qqq.backend.core.model.data.QRecordEntity; +import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior; /******************************************************************************* @@ -55,6 +56,12 @@ public class DbPerfConnectionSample extends QRecordEntity @QField private Integer connectionCount; + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE) + private Instant createDate; + + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE) + private Instant modifyDate; + /******************************************************************************* ** Default constructor. @@ -267,4 +274,60 @@ public class DbPerfConnectionSample extends QRecordEntity this.connectionCount = connectionCount; return (this); } + + + /******************************************************************************* + ** Getter for createDate. + *******************************************************************************/ + public Instant getCreateDate() + { + return (this.createDate); + } + + + /******************************************************************************* + ** Setter for createDate. + *******************************************************************************/ + public void setCreateDate(Instant createDate) + { + this.createDate = createDate; + } + + + /******************************************************************************* + ** Fluent setter for createDate. + *******************************************************************************/ + public DbPerfConnectionSample withCreateDate(Instant createDate) + { + this.createDate = createDate; + return (this); + } + + + /******************************************************************************* + ** Getter for modifyDate. + *******************************************************************************/ + public Instant getModifyDate() + { + return (this.modifyDate); + } + + + /******************************************************************************* + ** Setter for modifyDate. + *******************************************************************************/ + public void setModifyDate(Instant modifyDate) + { + this.modifyDate = modifyDate; + } + + + /******************************************************************************* + ** Fluent setter for modifyDate. + *******************************************************************************/ + public DbPerfConnectionSample withModifyDate(Instant modifyDate) + { + this.modifyDate = modifyDate; + return (this); + } } diff --git a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfExplain.java b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfExplain.java index 51d30ad..91846f4 100644 --- a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfExplain.java +++ b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfExplain.java @@ -26,6 +26,7 @@ import java.time.Instant; import com.kingsrook.qqq.backend.core.model.data.QField; import com.kingsrook.qqq.backend.core.model.data.QRecord; import com.kingsrook.qqq.backend.core.model.data.QRecordEntity; +import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior; /******************************************************************************* @@ -77,6 +78,12 @@ public class DbPerfExplain extends QRecordEntity @QField private BigDecimal totalCost; + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE) + private Instant createDate; + + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE) + private Instant modifyDate; + /******************************************************************************* ** Default constructor. @@ -485,4 +492,60 @@ public class DbPerfExplain extends QRecordEntity this.totalCost = totalCost; return (this); } + + + /******************************************************************************* + ** Getter for createDate. + *******************************************************************************/ + public Instant getCreateDate() + { + return (this.createDate); + } + + + /******************************************************************************* + ** Setter for createDate. + *******************************************************************************/ + public void setCreateDate(Instant createDate) + { + this.createDate = createDate; + } + + + /******************************************************************************* + ** Fluent setter for createDate. + *******************************************************************************/ + public DbPerfExplain withCreateDate(Instant createDate) + { + this.createDate = createDate; + return (this); + } + + + /******************************************************************************* + ** Getter for modifyDate. + *******************************************************************************/ + public Instant getModifyDate() + { + return (this.modifyDate); + } + + + /******************************************************************************* + ** Setter for modifyDate. + *******************************************************************************/ + public void setModifyDate(Instant modifyDate) + { + this.modifyDate = modifyDate; + } + + + /******************************************************************************* + ** Fluent setter for modifyDate. + *******************************************************************************/ + public DbPerfExplain withModifyDate(Instant modifyDate) + { + this.modifyDate = modifyDate; + return (this); + } } diff --git a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfFinding.java b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfFinding.java index 670dcc7..d86c2aa 100644 --- a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfFinding.java +++ b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfFinding.java @@ -26,6 +26,7 @@ import java.time.Instant; import com.kingsrook.qqq.backend.core.model.data.QField; import com.kingsrook.qqq.backend.core.model.data.QRecord; import com.kingsrook.qqq.backend.core.model.data.QRecordEntity; +import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior; /******************************************************************************* @@ -107,10 +108,10 @@ public class DbPerfFinding extends QRecordEntity @QField(maxLength = 100) private String statusChangedBy; - @QField + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE) private Instant createDate; - @QField + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE) private Instant modifyDate; diff --git a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfIndexStat.java b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfIndexStat.java index c26ae66..6309db0 100644 --- a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfIndexStat.java +++ b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfIndexStat.java @@ -25,6 +25,7 @@ import java.time.Instant; import com.kingsrook.qqq.backend.core.model.data.QField; import com.kingsrook.qqq.backend.core.model.data.QRecord; import com.kingsrook.qqq.backend.core.model.data.QRecordEntity; +import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior; /******************************************************************************* @@ -91,10 +92,10 @@ public class DbPerfIndexStat extends QRecordEntity @QField private Instant lastSeenAt; - @QField + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE) private Instant createDate; - @QField + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE) private Instant modifyDate; diff --git a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfQueryDaily.java b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfQueryDaily.java index 260c0ad..3e8fc05 100644 --- a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfQueryDaily.java +++ b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfQueryDaily.java @@ -22,10 +22,12 @@ package com.kingsrook.qbits.dbperformance.model; import java.math.BigDecimal; +import java.time.Instant; import java.time.LocalDate; import com.kingsrook.qqq.backend.core.model.data.QField; import com.kingsrook.qqq.backend.core.model.data.QRecord; import com.kingsrook.qqq.backend.core.model.data.QRecordEntity; +import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior; /******************************************************************************* @@ -68,6 +70,12 @@ public class DbPerfQueryDaily extends QRecordEntity @QField private Integer snapshots; + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE) + private Instant createDate; + + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE) + private Instant modifyDate; + /******************************************************************************* ** Default constructor. @@ -392,4 +400,60 @@ public class DbPerfQueryDaily extends QRecordEntity this.snapshots = snapshots; return (this); } + + + /******************************************************************************* + ** Getter for createDate. + *******************************************************************************/ + public Instant getCreateDate() + { + return (this.createDate); + } + + + /******************************************************************************* + ** Setter for createDate. + *******************************************************************************/ + public void setCreateDate(Instant createDate) + { + this.createDate = createDate; + } + + + /******************************************************************************* + ** Fluent setter for createDate. + *******************************************************************************/ + public DbPerfQueryDaily withCreateDate(Instant createDate) + { + this.createDate = createDate; + return (this); + } + + + /******************************************************************************* + ** Getter for modifyDate. + *******************************************************************************/ + public Instant getModifyDate() + { + return (this.modifyDate); + } + + + /******************************************************************************* + ** Setter for modifyDate. + *******************************************************************************/ + public void setModifyDate(Instant modifyDate) + { + this.modifyDate = modifyDate; + } + + + /******************************************************************************* + ** Fluent setter for modifyDate. + *******************************************************************************/ + public DbPerfQueryDaily withModifyDate(Instant modifyDate) + { + this.modifyDate = modifyDate; + return (this); + } } diff --git a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfQuerySnapshot.java b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfQuerySnapshot.java index f5af641..acd9b8c 100644 --- a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfQuerySnapshot.java +++ b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfQuerySnapshot.java @@ -26,6 +26,7 @@ import java.time.Instant; import com.kingsrook.qqq.backend.core.model.data.QField; import com.kingsrook.qqq.backend.core.model.data.QRecord; import com.kingsrook.qqq.backend.core.model.data.QRecordEntity; +import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior; /******************************************************************************* @@ -77,6 +78,12 @@ public class DbPerfQuerySnapshot extends QRecordEntity @QField private BigDecimal shareOfDbTime; + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE) + private Instant createDate; + + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE) + private Instant modifyDate; + /******************************************************************************* ** Default constructor. @@ -485,4 +492,60 @@ public class DbPerfQuerySnapshot extends QRecordEntity this.shareOfDbTime = shareOfDbTime; return (this); } + + + /******************************************************************************* + ** Getter for createDate. + *******************************************************************************/ + public Instant getCreateDate() + { + return (this.createDate); + } + + + /******************************************************************************* + ** Setter for createDate. + *******************************************************************************/ + public void setCreateDate(Instant createDate) + { + this.createDate = createDate; + } + + + /******************************************************************************* + ** Fluent setter for createDate. + *******************************************************************************/ + public DbPerfQuerySnapshot withCreateDate(Instant createDate) + { + this.createDate = createDate; + return (this); + } + + + /******************************************************************************* + ** Getter for modifyDate. + *******************************************************************************/ + public Instant getModifyDate() + { + return (this.modifyDate); + } + + + /******************************************************************************* + ** Setter for modifyDate. + *******************************************************************************/ + public void setModifyDate(Instant modifyDate) + { + this.modifyDate = modifyDate; + } + + + /******************************************************************************* + ** Fluent setter for modifyDate. + *******************************************************************************/ + public DbPerfQuerySnapshot withModifyDate(Instant modifyDate) + { + this.modifyDate = modifyDate; + return (this); + } } diff --git a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfRepeatPattern.java b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfRepeatPattern.java index ca7c146..d8861f2 100644 --- a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfRepeatPattern.java +++ b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfRepeatPattern.java @@ -26,6 +26,7 @@ import java.time.Instant; import com.kingsrook.qqq.backend.core.model.data.QField; import com.kingsrook.qqq.backend.core.model.data.QRecord; import com.kingsrook.qqq.backend.core.model.data.QRecordEntity; +import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior; /******************************************************************************* @@ -77,6 +78,12 @@ public class DbPerfRepeatPattern extends QRecordEntity @QField private BigDecimal sampleRate; + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE) + private Instant createDate; + + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE) + private Instant modifyDate; + /******************************************************************************* ** Default constructor. @@ -484,4 +491,60 @@ public class DbPerfRepeatPattern extends QRecordEntity this.sampleRate = sampleRate; return (this); } + + + /******************************************************************************* + ** Getter for createDate. + *******************************************************************************/ + public Instant getCreateDate() + { + return (this.createDate); + } + + + /******************************************************************************* + ** Setter for createDate. + *******************************************************************************/ + public void setCreateDate(Instant createDate) + { + this.createDate = createDate; + } + + + /******************************************************************************* + ** Fluent setter for createDate. + *******************************************************************************/ + public DbPerfRepeatPattern withCreateDate(Instant createDate) + { + this.createDate = createDate; + return (this); + } + + + /******************************************************************************* + ** Getter for modifyDate. + *******************************************************************************/ + public Instant getModifyDate() + { + return (this.modifyDate); + } + + + /******************************************************************************* + ** Setter for modifyDate. + *******************************************************************************/ + public void setModifyDate(Instant modifyDate) + { + this.modifyDate = modifyDate; + } + + + /******************************************************************************* + ** Fluent setter for modifyDate. + *******************************************************************************/ + public DbPerfRepeatPattern withModifyDate(Instant modifyDate) + { + this.modifyDate = modifyDate; + return (this); + } } diff --git a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfRule.java b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfRule.java index 469585f..88bcbc4 100644 --- a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfRule.java +++ b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfRule.java @@ -26,6 +26,7 @@ import java.time.Instant; import com.kingsrook.qqq.backend.core.model.data.QField; import com.kingsrook.qqq.backend.core.model.data.QRecord; import com.kingsrook.qqq.backend.core.model.data.QRecordEntity; +import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior; /******************************************************************************* @@ -65,10 +66,10 @@ public class DbPerfRule extends QRecordEntity @QField(maxLength = 100) private String threshold2Label; - @QField + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE) private Instant createDate; - @QField + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE) private Instant modifyDate; diff --git a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfSettings.java b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfSettings.java index f8d6b83..50114c5 100644 --- a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfSettings.java +++ b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfSettings.java @@ -26,6 +26,7 @@ import java.time.Instant; import com.kingsrook.qqq.backend.core.model.data.QField; import com.kingsrook.qqq.backend.core.model.data.QRecord; import com.kingsrook.qqq.backend.core.model.data.QRecordEntity; +import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior; /******************************************************************************* @@ -113,10 +114,10 @@ public class DbPerfSettings extends QRecordEntity @QField(maxLength = 500) private String statsAccessMessage; - @QField + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE) private Instant createDate; - @QField + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE) private Instant modifyDate; diff --git a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfSnapshot.java b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfSnapshot.java index 20062a7..d9b495c 100644 --- a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfSnapshot.java +++ b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfSnapshot.java @@ -26,6 +26,7 @@ import java.time.Instant; import com.kingsrook.qqq.backend.core.model.data.QField; import com.kingsrook.qqq.backend.core.model.data.QRecord; import com.kingsrook.qqq.backend.core.model.data.QRecordEntity; +import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior; /******************************************************************************* @@ -119,9 +120,12 @@ public class DbPerfSnapshot extends QRecordEntity @QField private Integer storedStatementCount; - @QField + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE) private Instant createDate; + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE) + private Instant modifyDate; + @QField private Long rawXactCommit; @@ -1260,4 +1264,32 @@ public class DbPerfSnapshot extends QRecordEntity this.rawStatementStatsReset = rawStatementStatsReset; return (this); } + + + /******************************************************************************* + ** Getter for modifyDate. + *******************************************************************************/ + public Instant getModifyDate() + { + return (this.modifyDate); + } + + + /******************************************************************************* + ** Setter for modifyDate. + *******************************************************************************/ + public void setModifyDate(Instant modifyDate) + { + this.modifyDate = modifyDate; + } + + + /******************************************************************************* + ** Fluent setter for modifyDate. + *******************************************************************************/ + public DbPerfSnapshot withModifyDate(Instant modifyDate) + { + this.modifyDate = modifyDate; + return (this); + } } diff --git a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfStatement.java b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfStatement.java index ad76f85..6e0753f 100644 --- a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfStatement.java +++ b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfStatement.java @@ -26,6 +26,7 @@ import java.time.Instant; import com.kingsrook.qqq.backend.core.model.data.QField; import com.kingsrook.qqq.backend.core.model.data.QRecord; import com.kingsrook.qqq.backend.core.model.data.QRecordEntity; +import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior; /******************************************************************************* @@ -104,10 +105,10 @@ public class DbPerfStatement extends QRecordEntity @QField private BigDecimal shareOfDbTime24h; - @QField + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE) private Instant createDate; - @QField + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE) private Instant modifyDate; diff --git a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfTableDaily.java b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfTableDaily.java index af1bc1c..d20b5ff 100644 --- a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfTableDaily.java +++ b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfTableDaily.java @@ -21,10 +21,12 @@ package com.kingsrook.qbits.dbperformance.model; +import java.time.Instant; import java.time.LocalDate; import com.kingsrook.qqq.backend.core.model.data.QField; import com.kingsrook.qqq.backend.core.model.data.QRecord; import com.kingsrook.qqq.backend.core.model.data.QRecordEntity; +import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior; /******************************************************************************* @@ -70,6 +72,12 @@ public class DbPerfTableDaily extends QRecordEntity @QField private Long totalBytes; + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE) + private Instant createDate; + + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE) + private Instant modifyDate; + /******************************************************************************* ** Default constructor. @@ -422,4 +430,60 @@ public class DbPerfTableDaily extends QRecordEntity this.totalBytes = totalBytes; return (this); } + + + /******************************************************************************* + ** Getter for createDate. + *******************************************************************************/ + public Instant getCreateDate() + { + return (this.createDate); + } + + + /******************************************************************************* + ** Setter for createDate. + *******************************************************************************/ + public void setCreateDate(Instant createDate) + { + this.createDate = createDate; + } + + + /******************************************************************************* + ** Fluent setter for createDate. + *******************************************************************************/ + public DbPerfTableDaily withCreateDate(Instant createDate) + { + this.createDate = createDate; + return (this); + } + + + /******************************************************************************* + ** Getter for modifyDate. + *******************************************************************************/ + public Instant getModifyDate() + { + return (this.modifyDate); + } + + + /******************************************************************************* + ** Setter for modifyDate. + *******************************************************************************/ + public void setModifyDate(Instant modifyDate) + { + this.modifyDate = modifyDate; + } + + + /******************************************************************************* + ** Fluent setter for modifyDate. + *******************************************************************************/ + public DbPerfTableDaily withModifyDate(Instant modifyDate) + { + this.modifyDate = modifyDate; + return (this); + } } diff --git a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfTableSnapshot.java b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfTableSnapshot.java index e00a83f..d48b082 100644 --- a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfTableSnapshot.java +++ b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfTableSnapshot.java @@ -25,6 +25,7 @@ import java.time.Instant; import com.kingsrook.qqq.backend.core.model.data.QField; import com.kingsrook.qqq.backend.core.model.data.QRecord; import com.kingsrook.qqq.backend.core.model.data.QRecordEntity; +import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior; /******************************************************************************* @@ -94,6 +95,12 @@ public class DbPerfTableSnapshot extends QRecordEntity @QField private Long freezeAge; + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE) + private Instant createDate; + + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE) + private Instant modifyDate; + /******************************************************************************* ** Default constructor. @@ -670,4 +677,60 @@ public class DbPerfTableSnapshot extends QRecordEntity this.freezeAge = freezeAge; return (this); } + + + /******************************************************************************* + ** Getter for createDate. + *******************************************************************************/ + public Instant getCreateDate() + { + return (this.createDate); + } + + + /******************************************************************************* + ** Setter for createDate. + *******************************************************************************/ + public void setCreateDate(Instant createDate) + { + this.createDate = createDate; + } + + + /******************************************************************************* + ** Fluent setter for createDate. + *******************************************************************************/ + public DbPerfTableSnapshot withCreateDate(Instant createDate) + { + this.createDate = createDate; + return (this); + } + + + /******************************************************************************* + ** Getter for modifyDate. + *******************************************************************************/ + public Instant getModifyDate() + { + return (this.modifyDate); + } + + + /******************************************************************************* + ** Setter for modifyDate. + *******************************************************************************/ + public void setModifyDate(Instant modifyDate) + { + this.modifyDate = modifyDate; + } + + + /******************************************************************************* + ** Fluent setter for modifyDate. + *******************************************************************************/ + public DbPerfTableSnapshot withModifyDate(Instant modifyDate) + { + this.modifyDate = modifyDate; + return (this); + } } diff --git a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfTableStat.java b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfTableStat.java index e9989e9..1478406 100644 --- a/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfTableStat.java +++ b/src/main/java/com/kingsrook/qbits/dbperformance/model/DbPerfTableStat.java @@ -26,6 +26,7 @@ import java.time.Instant; import com.kingsrook.qqq.backend.core.model.data.QField; import com.kingsrook.qqq.backend.core.model.data.QRecord; import com.kingsrook.qqq.backend.core.model.data.QRecordEntity; +import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior; /******************************************************************************* @@ -131,10 +132,10 @@ public class DbPerfTableStat extends QRecordEntity @QField private Instant lastSeenAt; - @QField + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE) private Instant createDate; - @QField + @QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE) private Instant modifyDate; diff --git a/src/main/resources/db/liquibase/qbit-db-performance/db_performance.changelog.sql b/src/main/resources/db/liquibase/qbit-db-performance/db_performance.changelog.sql index 738bb1c..05e831b 100644 --- a/src/main/resources/db/liquibase/qbit-db-performance/db_performance.changelog.sql +++ b/src/main/resources/db/liquibase/qbit-db-performance/db_performance.changelog.sql @@ -609,3 +609,94 @@ SELECT 'DEADLOCKS', 'Deadlocks', 'Transactions that deadlocked and were cancelle -- changeset qbit-db-performance:34 -- comment: Repeated Statements: the sampling rate of each window, so repeat counts can be read at scale. ALTER TABLE db_perf_repeat_pattern ADD COLUMN IF NOT EXISTS sample_rate DECIMAL(5,4); + +-- changeset qbit-db-performance:35 +-- comment: Query Snapshots: Created and Modified dates. Existing rows get captured_at. The column default covers rows written by a release that does not set them. +ALTER TABLE db_perf_query_snapshot ADD COLUMN IF NOT EXISTS create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE db_perf_query_snapshot ADD COLUMN IF NOT EXISTS modify_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +UPDATE db_perf_query_snapshot SET create_date = captured_at, modify_date = captured_at WHERE captured_at IS NOT NULL; + +-- changeset qbit-db-performance:36 +-- comment: Table Snapshots: Created and Modified dates. Existing rows get captured_at. The column default covers rows written by a release that does not set them. +ALTER TABLE db_perf_table_snapshot ADD COLUMN IF NOT EXISTS create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE db_perf_table_snapshot ADD COLUMN IF NOT EXISTS modify_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +UPDATE db_perf_table_snapshot SET create_date = captured_at, modify_date = captured_at WHERE captured_at IS NOT NULL; + +-- changeset qbit-db-performance:37 +-- comment: Activity Samples: Created and Modified dates. Existing rows get captured_at. The column default covers rows written by a release that does not set them. +ALTER TABLE db_perf_activity_sample ADD COLUMN IF NOT EXISTS create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE db_perf_activity_sample ADD COLUMN IF NOT EXISTS modify_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +UPDATE db_perf_activity_sample SET create_date = captured_at, modify_date = captured_at WHERE captured_at IS NOT NULL; + +-- changeset qbit-db-performance:38 +-- comment: Connection Samples: Created and Modified dates. Existing rows get captured_at. The column default covers rows written by a release that does not set them. +ALTER TABLE db_perf_connection_sample ADD COLUMN IF NOT EXISTS create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE db_perf_connection_sample ADD COLUMN IF NOT EXISTS modify_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +UPDATE db_perf_connection_sample SET create_date = captured_at, modify_date = captured_at WHERE captured_at IS NOT NULL; + +-- changeset qbit-db-performance:39 +-- comment: Query Plans: Created and Modified dates. Existing rows get requested_at. The column default covers rows written by a release that does not set them. +ALTER TABLE db_perf_explain ADD COLUMN IF NOT EXISTS create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE db_perf_explain ADD COLUMN IF NOT EXISTS modify_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +UPDATE db_perf_explain SET create_date = requested_at, modify_date = requested_at WHERE requested_at IS NOT NULL; + +-- changeset qbit-db-performance:40 +-- comment: Query Daily: Created and Modified dates. Existing rows get the time of the migration. The column default covers rows written by a release that does not set them. +ALTER TABLE db_perf_query_daily ADD COLUMN IF NOT EXISTS create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE db_perf_query_daily ADD COLUMN IF NOT EXISTS modify_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; + +-- changeset qbit-db-performance:41 +-- comment: Table Daily: Created and Modified dates. Existing rows get the time of the migration. The column default covers rows written by a release that does not set them. +ALTER TABLE db_perf_table_daily ADD COLUMN IF NOT EXISTS create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE db_perf_table_daily ADD COLUMN IF NOT EXISTS modify_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; + +-- changeset qbit-db-performance:42 +-- comment: Attribution: Created and Modified dates. Existing rows get the time of the migration. The column default covers rows written by a release that does not set them. +ALTER TABLE db_perf_attribution ADD COLUMN IF NOT EXISTS create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE db_perf_attribution ADD COLUMN IF NOT EXISTS modify_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; + +-- changeset qbit-db-performance:43 +-- comment: Attribution Daily: Created and Modified dates. Existing rows get the time of the migration. The column default covers rows written by a release that does not set them. +ALTER TABLE db_perf_attribution_daily ADD COLUMN IF NOT EXISTS create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE db_perf_attribution_daily ADD COLUMN IF NOT EXISTS modify_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; + +-- changeset qbit-db-performance:44 +-- comment: Repeated Statements: Created and Modified dates. Existing rows get the time of the migration. The column default covers rows written by a release that does not set them. +ALTER TABLE db_perf_repeat_pattern ADD COLUMN IF NOT EXISTS create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE db_perf_repeat_pattern ADD COLUMN IF NOT EXISTS modify_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; + +-- changeset qbit-db-performance:45 +-- comment: Snapshots: Modified date. Existing rows copy the capture time. +ALTER TABLE db_perf_snapshot ADD COLUMN IF NOT EXISTS modify_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +UPDATE db_perf_snapshot SET create_date = captured_at WHERE create_date IS NULL; +UPDATE db_perf_snapshot SET modify_date = create_date WHERE create_date IS NOT NULL; + +-- changeset qbit-db-performance:46 +-- comment: Queries: fill Created and Modified dates left empty by earlier releases. +UPDATE db_perf_statement SET create_date = COALESCE(first_seen_at, CURRENT_TIMESTAMP) WHERE create_date IS NULL; +UPDATE db_perf_statement SET modify_date = create_date WHERE modify_date IS NULL; + +-- changeset qbit-db-performance:47 +-- comment: Findings: fill Created and Modified dates left empty by earlier releases. +UPDATE db_perf_finding SET create_date = COALESCE(first_seen_at, CURRENT_TIMESTAMP) WHERE create_date IS NULL; +UPDATE db_perf_finding SET modify_date = create_date WHERE modify_date IS NULL; + +-- changeset qbit-db-performance:48 +-- comment: Settings: fill Created and Modified dates left empty by earlier releases. +UPDATE db_perf_settings SET create_date = CURRENT_TIMESTAMP WHERE create_date IS NULL; +UPDATE db_perf_settings SET modify_date = create_date WHERE modify_date IS NULL; + +-- changeset qbit-db-performance:49 +-- comment: Suggestion Rules: fill Created and Modified dates left empty by earlier releases. +UPDATE db_perf_rule SET create_date = CURRENT_TIMESTAMP WHERE create_date IS NULL; +UPDATE db_perf_rule SET modify_date = create_date WHERE modify_date IS NULL; + +-- changeset qbit-db-performance:50 +-- comment: Tables: fill Created and Modified dates left empty by earlier releases. +UPDATE db_perf_table_stat SET create_date = CURRENT_TIMESTAMP WHERE create_date IS NULL; +UPDATE db_perf_table_stat SET modify_date = create_date WHERE modify_date IS NULL; + +-- changeset qbit-db-performance:51 +-- comment: Indexes: fill Created and Modified dates left empty by earlier releases. +UPDATE db_perf_index_stat SET create_date = CURRENT_TIMESTAMP WHERE create_date IS NULL; +UPDATE db_perf_index_stat SET modify_date = create_date WHERE modify_date IS NULL; diff --git a/src/test/java/com/kingsrook/qbits/dbperformance/DbPerfTableStandardTest.java b/src/test/java/com/kingsrook/qbits/dbperformance/DbPerfTableStandardTest.java new file mode 100644 index 0000000..b4fa9d3 --- /dev/null +++ b/src/test/java/com/kingsrook/qbits/dbperformance/DbPerfTableStandardTest.java @@ -0,0 +1,188 @@ +/* + * QQQ - Low-code Application Framework for Engineers. + * Copyright (C) 2021-2026. Kingsrook, LLC + * 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States + * contact@kingsrook.com + * https://github.com/Kingsrook/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.kingsrook.qbits.dbperformance; + + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.Statement; +import java.time.Instant; +import java.util.List; +import java.util.UUID; +import com.kingsrook.qbits.dbperformance.collect.DbPerfStore; +import com.kingsrook.qbits.dbperformance.metadata.DbPerfMetaData; +import com.kingsrook.qqq.backend.core.model.actions.tables.query.QQueryFilter; +import com.kingsrook.qqq.backend.core.model.data.QRecord; +import com.kingsrook.qqq.backend.core.model.metadata.QInstance; +import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior; +import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldMetaData; +import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldType; +import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData; +import com.kingsrook.qqq.backend.module.rdbms.model.metadata.RDBMSBackendMetaData; +import liquibase.Liquibase; +import liquibase.database.DatabaseFactory; +import liquibase.database.jvm.JdbcConnection; +import liquibase.resource.ClassLoaderResourceAccessor; +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + + +/******************************************************************************* + ** Every table has createDate and modifyDate, declared, shipped and written. + *******************************************************************************/ +class DbPerfTableStandardTest +{ + /******************************************************************************* + ** Every declared table has both dates, typed and maintained by QQQ. + *******************************************************************************/ + @Test + void everyTableDeclaresBothDates() throws Exception + { + QInstance instance = DbPerfTestSupport.instance(); + assertThat(instance.getTables()).hasSize(DbPerfMetaData.TABLES.size()); + for(QTableMetaData table : instance.getTables().values()) + { + assertDate(table, "createDate", DynamicDefaultValueBehavior.CREATE_DATE); + assertDate(table, "modifyDate", DynamicDefaultValueBehavior.MODIFY_DATE); + } + } + + + + /******************************************************************************* + ** One field of the standard. + *******************************************************************************/ + private void assertDate(QTableMetaData table, String name, DynamicDefaultValueBehavior behavior) + { + QFieldMetaData field = table.getFields().get(name); + assertThat(field).as(table.getName() + "." + name).isNotNull(); + assertThat(field.getType()).as(table.getName() + "." + name).isEqualTo(QFieldType.DATE_TIME); + assertThat(field.getIsEditable()).as(table.getName() + "." + name).isFalse(); + assertThat(field.getBehaviors()).as(table.getName() + "." + name).contains(behavior); + } + + + + /******************************************************************************* + ** The shipped changelog creates both columns on every table. + *******************************************************************************/ + @Test + void changelogCreatesBothColumns() throws Exception + { + QInstance instance = DbPerfTestSupport.instance(); + RDBMSBackendMetaData backend = (RDBMSBackendMetaData) instance.getBackends().values().iterator().next(); + try(Connection connection = DriverManager.getConnection(backend.getJdbcUrl(), "sa", ""); Statement statement = connection.createStatement()) + { + for(String table : DbPerfMetaData.TABLES) + { + for(String column : List.of("create_date", "modify_date")) + { + try(ResultSet rows = statement.executeQuery("SELECT count(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE LOWER(TABLE_NAME) = '" + table + "' AND LOWER(COLUMN_NAME) = '" + column + "'")) + { + rows.next(); + assertThat(rows.getInt(1)).as(table + "." + column).isEqualTo(1); + } + } + } + + ///////////////////////////////////////////////////////////////////// + // a row written by a release that does not know the columns still // + // gets both // + ///////////////////////////////////////////////////////////////////// + statement.executeUpdate("INSERT INTO db_perf_attribution (unit_name) VALUES ('older release')"); + try(ResultSet rows = statement.executeQuery("SELECT create_date, modify_date FROM db_perf_attribution WHERE unit_name = 'older release'")) + { + rows.next(); + assertThat(rows.getTimestamp(1)).isNotNull(); + assertThat(rows.getTimestamp(2)).isNotNull(); + } + } + } + + + + /******************************************************************************* + ** Rows written through the QBit's store (QQQ actions) get createDate on insert + ** and a later modifyDate on update. + *******************************************************************************/ + @Test + void storeWritesMaintainBothDates() throws Exception + { + DbPerfTestSupport.instance(); + DbPerfStore.insert("db_perf_attribution", List.of(new QRecord().withValue("unitName", "example"))); + QRecord inserted = DbPerfStore.query("db_perf_attribution", new QQueryFilter()).getFirst(); + Instant created = inserted.getValueInstant("createDate"); + assertThat(created).isNotNull(); + assertThat(inserted.getValueInstant("modifyDate")).isNotNull(); + Thread.sleep(50); + DbPerfStore.update("db_perf_attribution", List.of(new QRecord().withValue("id", inserted.getValue("id")).withValue("unitName", "changed"))); + QRecord updated = DbPerfStore.query("db_perf_attribution", new QQueryFilter()).getFirst(); + assertThat(updated.getValueInstant("createDate")).isEqualTo(created); + assertThat(updated.getValueInstant("modifyDate")).isAfter(inserted.getValueInstant("modifyDate")); + } + + + + /******************************************************************************* + ** Upgrading from the previous changelog fills the new columns on existing rows. + *******************************************************************************/ + @Test + void upgradeFillsExistingRows() throws Exception + { + String name = "dbperf" + UUID.randomUUID().toString().replace("-", ""); + String url = "jdbc:h2:mem:" + name + ";CASE_INSENSITIVE_IDENTIFIERS=TRUE;DB_CLOSE_DELAY=-1;MODE=PostgreSQL"; + try(Connection connection = DriverManager.getConnection(url, "sa", ""); + Liquibase liquibase = new Liquibase(DbPerfMetaData.CHANGELOG, new ClassLoaderResourceAccessor(), DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection))); + Statement statement = connection.createStatement()) + { + liquibase.update(34, ""); + statement.executeUpdate("INSERT INTO db_perf_snapshot (backend_name, captured_at) VALUES ('b', TIMESTAMP '2026-01-02 03:04:05')"); + statement.executeUpdate("INSERT INTO db_perf_query_snapshot (captured_at) VALUES (TIMESTAMP '2026-01-02 03:04:05')"); + statement.executeUpdate("INSERT INTO db_perf_attribution (unit_name) VALUES ('x')"); + statement.executeUpdate("INSERT INTO db_perf_statement (backend_name, first_seen_at) VALUES ('b', TIMESTAMP '2026-02-03 04:05:06')"); + liquibase.update(""); + assertThat(timestamps(statement, "db_perf_snapshot")).containsExactly("2026-01-02 03:04:05", "2026-01-02 03:04:05"); + assertThat(timestamps(statement, "db_perf_query_snapshot")).containsExactly("2026-01-02 03:04:05", "2026-01-02 03:04:05"); + assertThat(timestamps(statement, "db_perf_statement")).containsExactly("2026-02-03 04:05:06", "2026-02-03 04:05:06"); + assertThat(timestamps(statement, "db_perf_attribution")).doesNotContainNull(); + try(ResultSet rows = statement.executeQuery("SELECT count(*) FROM db_perf_rule WHERE create_date IS NULL OR modify_date IS NULL")) + { + rows.next(); + assertThat(rows.getInt(1)).isZero(); + } + } + } + + + + /******************************************************************************* + ** The two dates of the only row of a table, as text. + *******************************************************************************/ + private List timestamps(Statement statement, String table) throws Exception + { + try(ResultSet rows = statement.executeQuery("SELECT create_date, modify_date FROM " + table)) + { + assertThat(rows.next()).isTrue(); + return (List.of(rows.getTimestamp(1).toString().substring(0, 19), rows.getTimestamp(2).toString().substring(0, 19))); + } + } +}