Skip to content

Fixes #23002: Add createdAt/createdBy creation audit and show table creation time - #34025

Merged
mohityadav766 merged 16 commits into
mainfrom
feature/entity-creation-audit-23002
Oct 5, 2026
Merged

mohityadav766 merged 16 commits into
mainfrom
feature/entity-creation-audit-23002

Conversation

@mohityadav766

@mohityadav766 mohityadav766 commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Describe your changes:

Fixes #23002

The issue asks for a table creation time that connectors know where to put and the UI can show. This PR does three things:

  1. Creation audit fields. Adds createdAt / createdBy on 15 entities as the counterpart to updatedAt / updatedBy. This follows the direction on this issue ("add it for EntityInterface") and the review of the closed Added creation time in data, user and team entities #24412 ("change creationTime to createdAt like we have updatedAt", "also add createdBy"). These fields record when and by whom an entity was created in OpenMetadata.
  2. Source-system creation time in the Table header. This data is already collected. BIGQUERY_LIFE_CYCLE_QUERY runs the same INFORMATION_SCHEMA.TABLES.creation_time query quoted in the issue, and BigQuery, Snowflake and Redshift write the result to lifeCycle.created.timestamp. It was never rendered, so the Table header now shows it as Created Time. No new field was added for it.
  3. No more placeholder creation time (review fix). When a source reported no creation time, the ingestion life-cycle mixin stored datetime.min instead, so affected tables hold lifeCycle.created.timestamp = -62135596800000 and the new header would read "Jan 1, 0001". The mixin now leaves created unset, and a 2.1.0 migration removes the placeholders already stored.

Type of change:

  • New feature

High-level design:

Schema. 15 entity schemas get optional createdAt (timestamp) and createdBy (string) and implement a new CreationAudited interface: table, database, databaseSchema, dashboard, chart, dashboardDataModel, pipeline, topic, mlmodel, container, metric, query, user, team and role. The fields are server-assigned, so they are not added to any create* request schema.

Why CreationAudited and not EntityInterface. Task already declares a required createdBy of type EntityReference, so a String getCreatedBy() on EntityInterface does not compile. Renaming Task's field would let this collapse onto EntityInterface. I left that call to reviewers because it changes Task's published API.

Stamping on create. EntityRepository.setCreationAudit runs in the three create funnels (createNewEntity, createManyEntities, createManyEntitiesForImport). It derives from updatedAt / updatedBy, so a new entity has createdAt == updatedAt. The stamping deliberately does not happen in:

  • prepareInternal: PUT reaches create through EntityResource.createOrUpdate, which calls prepareInternal(entity, true). A !update hook there would skip every entity created by ingestion.
  • copy(): it runs on every PUT, so re-ingesting would reset the value. This is the bug in Added creation time in data, user and team entities #24412.

Immutability. carryCreationAudit(original, updated) copies the stored values onto the incoming entity in updateInternal, updateInternalForImport and the bulk updateMany loop. These are private paths that cover both PUT and PATCH, so no repository subclass can bypass them. The copy happens before diffing, so these fields never produce a change record or a version bump.

Backfill (2.1.0 data migration). CreationAuditMigration is wired into both v210/Migration classes and runs two passes, each only on rows where createdAt is absent. That makes it idempotent on MySQL and Postgres.

  1. Take updatedAt / updatedBy from the entity's oldest entity_extension version row.
  2. If there is no version history, fall back to the row's own updatedAt / updatedBy.

Run once per version. Both data-migration steps (this backfill and the placeholder repair below) go through a new DataMigrationStep.runOnce. It records a marker in SERVER_MIGRATION_SQL_LOGS when the step succeeds, and skips the step while that marker exists. Without it the steps would repeat. The framework re-runs a version's whole data migration whenever its fingerprint changes, and the fingerprint covers every class in utils/v210, so any v210 helper added later in the release would rerun the backfill's join over entity_extension. The marker is written through the migration's own handle, so it commits or rolls back with the step. A failed step records nothing and is retried.

Search. createdAt is indexed as date / epoch_millis and createdBy as keyword, across 14 index mappings in 4 locales (role has no index). Documents pick the fields up through JsonUtils.getMap. ⚠️ IndexMappingVersionTracker will reindex those indexes on upgrade.

Placeholder creation time (review fix). LifeCycleQueryMixin._build_access_details returned datetime.min for a missing timestamp. It now returns None, and get_life_cycle_data skips a table that has neither timestamp. The server keeps each stored aspect when the incoming one is empty, so that patch would change nothing. It also means ingestion can't remove a placeholder it stored earlier; only the migration below does. LifeCycleCreatedSentinelMigration (2.1.0, MySQL and Postgres) removes lifeCycle.created from table_entity rows whose timestamp is negative. Only tables get life-cycle data from that mixin, and no real table predates 1970. I fixed it at the producer rather than with a UI >= 0 guard, so API, search and MCP consumers stop seeing year 0001 too.

UI. getTableHeaderInfo renders lifeCycle.created.timestamp using the existing label.created-time key, which is already translated in all 20 locales. The guard is !== undefined, so an epoch-0 timestamp still renders.

Out of scope:

  • A separate Table.creationTime field (it would duplicate lifeCycle.created).
  • Extending lifeCycle collection beyond BigQuery, Snowflake and Redshift.
  • The other ~65 entity schemas.
  • Consolidating the profiler's createDateTime.

Tests:

Use cases covered

  • A newly created entity gets createdAt == updatedAt and createdBy == updatedBy, and both survive a GET.
  • A PATCH that tries to rewrite createdAt / createdBy leaves them unchanged while updatedAt moves forward.
  • The migration recovers creation audit from the oldest stored version.
  • The migration falls back to updatedAt / updatedBy when an entity has no version history.
  • Re-running the migration does not move an already-populated createdAt.
  • The Table header shows Created Time when lifeCycle.created is set, omits it when unset, and renders an epoch-0 value.
  • Ingestion leaves lifeCycle.created unset when the source reports no creation time, instead of storing datetime.min.
  • The 2.1.0 repair removes a stored placeholder creation time and leaves a real one untouched, however often it runs.
  • Once the backfill and the repair have run, a later re-run of 2.1.0 skips both instead of scanning the tables again.

Unit tests

  • Files: src/utils/DataAssetsHeader.utils.test.tsx (Table-case assertions plus an epoch-0 case) and src/mocks/TableData.mock.ts. Result: 23/23.

  • Coverage %: not measured. The Java changes (EntityRepository, CreationAuditMigration) are exercised by the integration tests below rather than by unit tests, so there is no JaCoCo number to report.

  • ingestion/tests/unit/topology/database/test_life_cycle_query_mixin.py: two new cases. A missing creation time stays unset instead of becoming datetime.min, and a table with no timestamps yields nothing. Both fail on the old mixin; 6/6 pass with the fix.

  • openmetadata-service/.../migration/utils/DataMigrationStepTest.java covers four cases: the step runs and records its marker when none exists, it is skipped while the marker exists, a failure records nothing, and each version gets a distinct marker. 4/4.

Backend integration tests

  • BaseEntityIT gains post_entityCreationAuditIsStamped_200 and patch_entityCreationAuditIsImmutable_200, gated by supportsCreationAudit. All 15 entity ITs opt in.
  • New CreationAuditMigrationIT runs the backfill against the real database: oldest-version recovery, the no-history fallback, and idempotency.
  • New LifeCycleCreatedSentinelMigrationIT runs the placeholder repair against the real database: it removes the placeholder and keeps a real value, idempotently.
  • Both migration ITs also test the gate end to end. The suite's bootstrap runs the real migration workflow, and a later runOnce for the same step is skipped. That covers the v210 wiring, the marker write and the marker lookup on each engine.
  • Run locally on this branch with the latest main merged in, using the reactor build (verify -am) with one Testcontainers stack per run:
    • Run-once gate (e4ae268d20): CreationAuditMigrationIT, LifeCycleCreatedSentinelMigrationIT, and the two Table audit tests. -Ppostgres-opensearch 9/9 and -Pmysql-elasticsearch 9/9, both BUILD SUCCESS, measured just before the latest main merge. After that merge (46b3ad0722) I re-ran Postgres: 9/9, together with the gate's unit tests and the framework's migration tests, 24/24.
    • Review fix (f8db18ae6a): LifeCycleCreatedSentinelMigrationIT, CreationAuditMigrationIT, and the two Table audit tests. -Ppostgres-opensearch 7/7 and -Pmysql-elasticsearch 7/7, both BUILD SUCCESS.
    • After merging main (aedda77d81): CreationAuditMigrationIT plus the audit tests in Table, User, Pipeline and Metric, and CI's failing GlossaryTermResourceIT#patch_removeOneRelationTypeKeepsOtherTypeForSameTerm as a control. -Ppostgres-opensearch 12/12, BUILD SUCCESS. The glossary failure does not reproduce on this branch.

Ingestion integration tests

  • Not applicable for connector ITs. The only ingestion change is in the shared LifeCycleQueryMixin, which the unit tests above cover. The new fields are not on any create* schema.

Playwright (UI) tests

  • New playwright/e2e/Pages/TableCreationTime.spec.ts covers the field being shown and being omitted. yarn lint:playwright reports 0 errors. I did not run it locally, so CI is the first run.
  • table-details-schema.png is unaffected: that test uses a fresh TableClass() with no lifeCycle.

Manual testing performed

I did not test against a running stack. To reproduce:

  1. Start this branch against a database that already has entities, so the 2.1.0 migration runs.
  2. Call GET /api/v1/tables/{id} on a pre-existing table and check that createdAt / createdBy are present.
  3. Create a table through the API and check that createdAt == updatedAt and createdBy is the caller. Re-send the same PUT and check that createdAt does not change.
  4. PATCH /lifeCycle to {"created": {"timestamp": 1609459200000}}. The Table page header should show Created Time.

UI screen recording / screenshots:

TODO: attach a recording of the Table page header showing Created Time for a table whose lifeCycle.created is set.

Checklist:

  • I have read the CONTRIBUTING document.

  • My PR title is Fixes <issue-number>: <short explanation>

  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.

  • I have commented on my code, particularly in hard-to-understand areas.

  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed. (See the 2.1.0 CreationAuditMigration and LifeCycleCreatedSentinelMigration.)

  • For UI changes: I attached a screen recording and/or screenshots above. (TODO, see above.)

  • I have added tests (unit / integration / Playwright as applicable) and listed them above.

  • The issue properly describes why the new feature is needed, what's the goal, and how we are building it. The direction is in the issue and in the Added creation time in data, user and team entities #24412 review, but the final design (CreationAudited, surfacing lifeCycle.created) is documented here, not in the issue.

  • I have updated the documentation. A follow-up should document lifeCycle.created as where connectors put source creation time.

  • I have added tests around the new logic.

🤖 Generated with Claude Code

Add OpenMetadata-internal creation audit, the counterpart to updatedAt/updatedBy, on 15 entities
(12 data assets plus user, team and role).

- Schemas declare createdAt/createdBy and implement a new CreationAudited interface. The accessors
  cannot live on EntityInterface: Task already declares a required createdBy of type
  EntityReference.
- EntityRepository stamps them in the three create funnels (createNewEntity, createManyEntities,
  createManyEntitiesForImport) and carries them from the stored entity in every update path, so
  PUT and PATCH cannot move them.
- A 2.1.0 data migration backfills existing rows from the oldest entity_extension version and falls
  back to the row's own updatedAt/updatedBy when there is no history. Idempotent on MySQL and
  Postgres.
- Search mappings index createdAt (epoch_millis) and createdBy (keyword).
- The Table header shows the source creation time that connectors already write to
  lifeCycle.created (BigQuery, Snowflake, Redshift).
@github-actions github-actions Bot added backend safe to test Add this label to run secure Github workflows on PRs labels Sep 25, 2026
@mohityadav766 mohityadav766 self-assigned this Sep 25, 2026
@mohityadav766
mohityadav766 marked this pull request as ready for review September 25, 2026 13:11
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Playwright impact map auto-refreshed

This PR touched specs or UI source that changed the source→spec routing map. I regenerated .github/playwright/impact-map.generated.json and pushed the diff to this branch.

- source entries: 801 → 801
- 0 added, 0 removed, 6 changed spec-list

Entries whose spec list changed:
  openmetadata-ui/src/main/resources/ui/playwright/e2e/fixtures/pages.ts
  openmetadata-ui/src/main/resources/ui/playwright/support/entity/TableClass.ts
  openmetadata-ui/src/main/resources/ui/playwright/utils/admin.ts
  openmetadata-ui/src/main/resources/ui/playwright/utils/common.ts
  openmetadata-ui/src/main/resources/ui/src/components/DataAssets/DataAssetsHeader/DataAssetsHeader.component.tsx
  openmetadata-ui/src/main/resources/ui/src/generated/entity/data/table.ts

What is this file? It is the auto-generated half of Playwright's PR planner. It routes "if source X changes, run specs Y" by walking spec imports and cross-referencing getByTestId strings. Hand-authored routing in impact-map.json always wins on conflict.

What if I want to regenerate locally instead? Run this before pushing your next change to skip the bot commit:

python3 .github/scripts/generate_playwright_impact_map.py
git add .github/playwright/impact-map.generated.json
git commit --amend --no-edit  # or a separate commit

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ UI Checkstyle passed — lint findings in changed files

🔍 ESLint findings in this PR's files — 0 error(s), 1 warning(s)

Errors block the build. Warnings do not yet — they are rules whose backlog is still
being worked down, listed so this PR does not add to it. See docs/ui-code-quality-gate.md.

0 error(s), 1 warning(s) across 1 changed file(s).

Count Rule
1 no-restricted-imports
All findings
Location Rule Message
🟡 src/utils/DataAssetsHeader.utils.tsx:22:1 no-restricted-imports '../assets/svg/external-links.svg' import is restricted from being used by a pattern. Do not import SVG icons directly from assets/ paths; use the designated ab

Fix locally (fast - only checks files changed in this branch):

make ui-checkstyle-changed

@github-actions

Copy link
Copy Markdown
Contributor

✅ Generated Sources Auto-Updated

The generated TypeScript types (src/generated/) and dereferenced JSON
schemas (src/jsons/, public/jsons/) have been automatically updated
based on JSON schema changes in this PR.

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit a4f5b9af90eab70441d63ae99420565d3b7295f8 in Playwright run 37202201455, attempt 1.

✅ 3411 passed · ❌ 0 failed · 🟡 4 flaky · ⏭️ 1 skipped · 🧰 0 lifecycle flaky

Performance

Blocking targets: ✅ met · Optimization targets: 🟡 in progress

Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting.

🕒 Full workflow signal wall (to summary) 50m 39s

⏱️ Max setup 4m 40s · max shard execution 19m 47s · max shard-job elapsed before upload 25m 52s · reporting 15s

🌐 212.67 requests/attempt · 2.02 app boots/UI scenario · 36.82% common-shard skew

Optimization targets still in progress:

  • Common shard skew was 36.82% (convergence target: at most 15%).
  • Browser traffic was 212.67 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.02 per UI scenario (7321 boots / 3622 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard advanced-search-01 66 0 0 0 0 0
✅ Shard advanced-search-02 64 0 0 0 0 0
🟡 Shard chromium-01 177 0 1 0 0 0
✅ Shard chromium-02 143 0 0 0 0 0
✅ Shard chromium-03 193 0 0 0 0 0
✅ Shard chromium-04 185 0 0 0 0 0
✅ Shard chromium-05 203 0 0 0 0 0
✅ Shard chromium-06 201 0 0 0 0 0
✅ Shard chromium-07 189 0 0 0 0 0
✅ Shard chromium-08 174 0 0 0 0 0
✅ Shard chromium-09 194 0 0 0 0 0
✅ Shard chromium-10 150 0 0 0 0 0
🟡 Shard chromium-11 214 0 1 0 0 0
✅ Shard chromium-12 149 0 0 0 0 0
✅ Shard chromium-13 182 0 0 0 0 0
✅ Shard chromium-14 181 0 0 0 0 0
🟡 Shard chromium-15 172 0 1 0 0 0
🟡 Shard chromium-16 147 0 1 1 0 0
✅ Shard data-asset-rules-01 65 0 0 0 0 0
✅ Shard global-state-01 67 0 0 0 0 0
✅ Shard import-export-01 97 0 0 0 0 0
✅ Shard import-export-02 55 0 0 0 0 0
✅ Shard ingestion-01 42 0 0 0 0 0
✅ Shard ingestion-02 51 0 0 0 0 0
✅ Shard reindex-01 41 0 0 0 0 0
✅ Shard search-rbac-01 9 0 0 0 0 0
🟡 4 flaky test(s) (passed on retry)
  • Pages/BotsProfile.spec.ts › should create bot via add form (shard chromium-01, 1 retry)
  • Flow/Metric.spec.ts › verify metric expression update (shard chromium-11, 1 retry)
  • Features/ExploreQuickFilters.spec.ts › should show correct count for tier filter options from aggregation (shard chromium-15, 1 retry)
  • Features/BulkEditEntity.spec.ts › Table (shard chromium-16, 1 retry)

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 75%
75.39% (114371/151691) 61.07% (70396/115259) 62.41% (23413/37513)

…on-audit-23002

# Conflicts:
#	openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java
When a source reported no creation time, LifeCycleQueryMixin substituted datetime.min, so affected
tables stored lifeCycle.created.timestamp = -62135596800000. The Table header added in this PR would
render that as "Created Time: Jan 1, 0001", and API, search and MCP consumers already received it.

- The mixin leaves `created` (and `updated`) unset when the source has no value. It still yields
  the record, so the sink, which replaces lifeCycle wholesale, clears a stored placeholder on the
  next run.
- A 2.1.0 migration, LifeCycleCreatedSentinelMigration, removes lifeCycle.created from table_entity
  rows with a negative timestamp, on MySQL and Postgres. Only tables receive life-cycle data from
  the mixin, and no real table predates 1970. Idempotent.
@mohityadav766
mohityadav766 requested a review from a team as a code owner September 29, 2026 18:05
mohityadav766 and others added 2 commits October 1, 2026 13:06
…on-audit-23002

# Conflicts:
#	openmetadata-service/src/main/java/org/openmetadata/service/migration/mysql/v210/Migration.java
#	openmetadata-service/src/main/java/org/openmetadata/service/migration/postgres/v210/Migration.java
mohityadav766 and others added 3 commits October 1, 2026 20:11
…23002)

The v210 data migration re-runs whenever its fingerprint changes, and the fingerprint covers every
class in utils/v210, so any helper added later in the release reran both steps. Their SQL was
already a no-op on a second run, but it still scanned the tables: the backfill's join over
entity_extension for 15 entity types, and a full table_entity scan for the repair.

- New DataMigrationStep.runOnce records a per-step marker in SERVER_MIGRATION_SQL_LOGS when a step
  succeeds and skips the step while the marker exists. The marker goes through the migration's own
  handle, so it commits or rolls back with the step, and a failed step is retried.
- Both v210 Migration classes run the creation-audit backfill and the lifeCycle placeholder repair
  through it.
- LifeCycleQueryMixin no longer yields a record for a table with neither timestamp. The server keeps
  each stored aspect when the incoming one is empty, so that patch changed nothing; only the
  migration can remove a stored placeholder. Corrected the comment that said otherwise.
mohityadav766 and others added 4 commits October 3, 2026 00:04
… the life-cycle Either

- IngestionPipelineMigrationEntryPointTest builds the v210 Migration by reflection and set only
  handle and collectionDAO. runDataMigration now gates its one-time steps through
  DataMigrationStep.runOnce, which reads migrationDAO, so the test needs one like the other
  collaborators.
- Re-indenting the `Either(right=...)` yield moved it off its basedpyright baseline entry, which
  matches by column range, so the existing reportCallIssue counted as new. Passing left=None
  satisfies the checker instead of adding a suppression.
@gitar-bot

gitar-bot Bot commented Oct 4, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 2 closed / 2 findings

🔴 High risk · 2.1.0 migrations backfill audit fields across 15 entities and remove stored timestamp values

Adds creation audit fields (createdAt/createdBy) to 15 entities, surfaces source system creation time in the Table header via existing lifeCycle.created data, and fixes the ingestion pipeline to leave creation time unset instead of storing a placeholder when the source reports none. A 2.1.0 migration backfills creation audit from version history and removes stored placeholders. All targeted use cases pass integration and unit tests across Postgres and MySQL.

✅ 2 closed
✅ Quality: Empty lifeCycle patch can't clear the stored placeholder created

📄 ingestion/src/metadata/ingestion/source/database/life_cycle_query_mixin.py:117-122 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java
The new comment says an empty LifeCycle is still yielded so that the sink replaces lifeCycle wholesale and clears a placeholder created. That doesn't happen. EntityUpdater.updateLifeCycle in EntityRepository copies the original created back whenever the incoming created is null (updatedLifeCycle.getCreated() == null → setCreated(origLifeCycle.getCreated())), so a placeholder stored by earlier runs stays put. Only the LifeCycleCreatedSentinelMigration actually removes it. As written, every table with no timestamps gets a PATCH that does nothing, and the comment points maintainers at the wrong mechanism. Either skip yielding when both aspects are None, or rewrite the comment to say the 2.1.0 migration does the cleanup.

Closed: Edge Case: Header shows year-0001 'Created Time' when source had no creation time

📄 openmetadata-ui/src/main/resources/ui/src/utils/DataAssetsHeader.utils.tsx:680-689
The ingestion mixin always sets lifeCycle.created. When the source row has no created_at, _build_access_details falls back to datetime.min, which ingests as roughly -62135596800000 ms. The new !== undefined guard lets that sentinel through, so any table whose source reported no creation time gets a header entry like "Created Time: Jan 1, 0001". The PR's premise is that this field was never rendered, so this sentinel has never been visible before. The fix is to skip values at or below the sentinel, for example by rendering only non-negative timestamps. That still shows epoch-0 as the PR intends. Also add a unit test for the negative case.

Review coverage

📋 Rules No rules evaluated

🧪 Functional validation Not enabled · Set up

🤖 Auto-approval Not enabled · Set up

Options

Display: compact → Counting what did not apply, without listing it.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@sonarqubecloud

sonarqubecloud Bot commented Oct 4, 2026

Copy link
Copy Markdown

@sonarqubecloud

sonarqubecloud Bot commented Oct 4, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-10-04T13:52:53Z)

Blocked the queue: integration-tests-mysql-elasticsearch

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-10-05T07:34:29Z)

Blocked the queue: integration-tests-mysql-elasticsearch

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-10-05T10:11:26Z)

Blocked the queue: integration-tests-mysql-elasticsearch

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add creationTime as a property of Table

4 participants