Add timestamp column to DB tables

Open
#2,478 0 comments 1 reaction 1 assignee View on GitHub

Maintainers usually reply within 1 day

@dopey is already working on this.

Since Mar 3, 2026.

Assessment

This issue has not been assessed yet.

Description

enhancement needs triage

Hello!

  • Vote on this issue by adding a 👍 reaction
  • If you want to implement this feature, comment to let us know (we'll work with you on design, scheduling, etc.)

Issue details

The database is "only" used as a key-value storage, all tables only have nkey and nvalue columns, which make it very hard to filter for new rows, as nkey is a random number and not incrementing at least as far as I understood. We want to create reports from the database, where we want to filter for new certificates for the last day for example.

Why is this needed?

When adding a new column like added_at to all tables it would be much easier to filter for new entries.

Currently we added the columns ourselves like so (for MySQL/MariaDB):

ALTER TABLE acme_account_orders_index                       ADD COLUMN added_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD INDEX idx_added_at (added_at);
ALTER TABLE acme_accounts                                   ADD COLUMN added_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD INDEX idx_added_at (added_at);
ALTER TABLE acme_authzs                                     ADD COLUMN added_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD INDEX idx_added_at (added_at);
ALTER TABLE acme_certs                                      ADD COLUMN added_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD INDEX idx_added_at (added_at);
ALTER TABLE acme_challenges                                 ADD COLUMN added_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD INDEX idx_added_at (added_at);
ALTER TABLE acme_external_account_keyID_provisionerID_index ADD COLUMN added_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD INDEX idx_added_at (added_at);
ALTER TABLE acme_external_account_keyID_reference_index     ADD COLUMN added_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD INDEX idx_added_at (added_at);
ALTER TABLE acme_external_account_keys                      ADD COLUMN added_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD INDEX idx_added_at (added_at);
ALTER TABLE acme_keyID_accountID_index                      ADD COLUMN added_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD INDEX idx_added_at (added_at);
ALTER TABLE acme_orders                                     ADD COLUMN added_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD INDEX idx_added_at (added_at);
ALTER TABLE acme_serial_certs_index                         ADD COLUMN added_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD INDEX idx_added_at (added_at);
ALTER TABLE nonces                                          ADD COLUMN added_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD INDEX idx_added_at (added_at);
ALTER TABLE revoked_ssh_certs                               ADD COLUMN added_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD INDEX idx_added_at (added_at);
ALTER TABLE revoked_x509_certs                              ADD COLUMN added_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD INDEX idx_added_at (added_at);
ALTER TABLE ssh_certs                                       ADD COLUMN added_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD INDEX idx_added_at (added_at);
ALTER TABLE ssh_host_principals                             ADD COLUMN added_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD INDEX idx_added_at (added_at);
ALTER TABLE ssh_hosts                                       ADD COLUMN added_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD INDEX idx_added_at (added_at);
ALTER TABLE ssh_users                                       ADD COLUMN added_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD INDEX idx_added_at (added_at);
ALTER TABLE used_ott                                        ADD COLUMN added_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD INDEX idx_added_at (added_at);
ALTER TABLE wire_acme_dpop_token                            ADD COLUMN added_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD INDEX idx_added_at (added_at);
ALTER TABLE wire_acme_oidc_token                            ADD COLUMN added_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD INDEX idx_added_at (added_at);
ALTER TABLE x509_certs                                      ADD COLUMN added_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD INDEX idx_added_at (added_at);
ALTER TABLE x509_certs_data                                 ADD COLUMN added_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD INDEX idx_added_at (added_at);
ALTER TABLE x509_crl                                        ADD COLUMN added_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD INDEX idx_added_at (added_at);

maybe it's an option to add such a column to the tables when creating them?

Dominant language
Go
Stars
8.9k
Forks
599
Avg merge
21h 20m
Merged PRs (30d)
15

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from smallstep/certificates

All issues in smallstep/certificates

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.