Add timestamp column to DB tables

Aperta
#2,478 0 commenti 1 reazione 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@dopey ci sta già lavorando.

Dal 3/3/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

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?

Lingua principale
Go
Stelle
8.9k
Fork
599
Merge medio
21h 20m
PR unite (30g)
15

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di smallstep/certificates

Tutte le issue di smallstep/certificates

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.