From 033b745315b876b664b47d6ddf113c9b44676ceb Mon Sep 17 00:00:00 2001 From: Tosone Date: Fri, 24 Nov 2023 20:27:07 +0800 Subject: [PATCH] :sparkles: Change namespaces created_at field type (#239) * :sparkles: Change namespaces created_at field type * :sparkles: Add index for all tables * :sparkles: Change created_at field type --- go.mod | 10 +- go.sum | 21 +- pkg/daemon/gc/gc_repository.go | 7 +- pkg/dal/dal.go | 20 +- pkg/dal/dao/artifact.go | 2 +- pkg/dal/dao/blob.go | 2 +- pkg/dal/dao/tag.go | 2 +- .../migrations/mysql/0001_initialize.up.sql | 325 ++++++++++------ .../postgresql/0001_initialize.up.sql | 358 +++++++++++++---- .../migrations/sqlite3/0001_initialize.up.sql | 360 ++++++++++++++---- pkg/dal/models/artifact.go | 12 +- pkg/dal/models/audit.go | 6 +- pkg/dal/models/blob.go | 4 +- pkg/dal/models/blob_upload.go | 6 +- pkg/dal/models/builder.go | 8 +- pkg/dal/models/cache.go | 6 +- pkg/dal/models/code_repository.go | 18 +- pkg/dal/models/daemon.go | 63 ++- pkg/dal/models/locker.go | 6 +- pkg/dal/models/namespace.go | 5 +- pkg/dal/models/namespace_member.go | 6 +- pkg/dal/models/reference.go | 21 - pkg/dal/models/repository.go | 6 +- pkg/dal/models/setting.go | 6 +- pkg/dal/models/tag.go | 4 +- pkg/dal/models/user.go | 12 +- pkg/dal/models/webhook.go | 10 +- pkg/dal/models/workq.go | 6 +- pkg/dal/query/artifact_sboms.gen.go | 18 +- pkg/dal/query/artifact_vulnerabilities.gen.go | 18 +- pkg/dal/query/artifacts.gen.go | 18 +- pkg/dal/query/audits.gen.go | 18 +- pkg/dal/query/blob_uploads.gen.go | 18 +- pkg/dal/query/blobs.gen.go | 18 +- pkg/dal/query/builder_runners.gen.go | 18 +- pkg/dal/query/builders.gen.go | 18 +- pkg/dal/query/caches.gen.go | 18 +- pkg/dal/query/code_repositories.gen.go | 18 +- pkg/dal/query/code_repository_branches.gen.go | 18 +- .../code_repository_clone_credentials.gen.go | 18 +- pkg/dal/query/code_repository_owners.gen.go | 18 +- .../query/daemon_gc_artifact_records.gen.go | 18 +- pkg/dal/query/daemon_gc_artifact_rules.gen.go | 18 +- .../query/daemon_gc_artifact_runners.gen.go | 18 +- pkg/dal/query/daemon_gc_blob_records.gen.go | 18 +- pkg/dal/query/daemon_gc_blob_rules.gen.go | 18 +- pkg/dal/query/daemon_gc_blob_runners.gen.go | 18 +- .../query/daemon_gc_repository_records.gen.go | 18 +- .../query/daemon_gc_repository_rules.gen.go | 18 +- .../query/daemon_gc_repository_runners.gen.go | 18 +- pkg/dal/query/daemon_gc_tag_records.gen.go | 18 +- pkg/dal/query/daemon_gc_tag_rules.gen.go | 18 +- pkg/dal/query/daemon_gc_tag_runners.gen.go | 18 +- pkg/dal/query/lockers.gen.go | 18 +- pkg/dal/query/namespace_members.gen.go | 18 +- pkg/dal/query/namespaces.gen.go | 18 +- pkg/dal/query/repositories.gen.go | 18 +- pkg/dal/query/settings.gen.go | 18 +- pkg/dal/query/tags.gen.go | 18 +- pkg/dal/query/user_3rdparty.gen.go | 18 +- pkg/dal/query/user_recover_codes.gen.go | 18 +- pkg/dal/query/users.gen.go | 18 +- pkg/dal/query/webhook_logs.gen.go | 18 +- pkg/dal/query/webhooks.gen.go | 18 +- pkg/dal/query/work_queues.gen.go | 18 +- pkg/handlers/artifacts/artifacts_get.go | 5 +- pkg/handlers/artifacts/artifacts_list.go | 17 +- pkg/handlers/builders/builders_runner_get.go | 4 +- .../builders/builders_runners_list.go | 4 +- pkg/handlers/coderepos/coderepos_branches.go | 5 +- pkg/handlers/coderepos/coderepos_get.go | 5 +- pkg/handlers/coderepos/coderepos_list.go | 5 +- .../coderepos/coderepos_owners_list.go | 5 +- .../coderepos/coderepos_user3rdparty.go | 5 +- pkg/handlers/daemons/daemons_gc_artifact.go | 24 +- pkg/handlers/daemons/daemons_gc_blob.go | 24 +- pkg/handlers/daemons/daemons_gc_repository.go | 24 +- pkg/handlers/daemons/daemons_gc_tags.go | 24 +- pkg/handlers/namespaces/namespaces_get.go | 31 +- pkg/handlers/namespaces/namespaces_list.go | 27 +- .../namespaces/namespaces_list_hot.go | 33 +- .../namespaces/namespaces_members_list.go | 19 +- .../namespaces/namespaces_members_self.go | 5 +- pkg/handlers/repositories/repositories_get.go | 5 +- .../repositories/repositories_list.go | 15 +- pkg/handlers/tags/tags_get.go | 14 +- pkg/handlers/tags/tags_list.go | 13 +- pkg/handlers/users/users_list.go | 22 +- pkg/handlers/webhooks/webhooks_get.go | 5 +- pkg/handlers/webhooks/webhooks_list.go | 5 +- pkg/handlers/webhooks/webhooks_log.go | 5 +- pkg/handlers/webhooks/webhooks_logs.go | 5 +- web/src/pages/Namespace/TableItem.tsx | 8 +- 93 files changed, 1423 insertions(+), 918 deletions(-) delete mode 100644 pkg/dal/models/reference.go diff --git a/go.mod b/go.mod index c0047174..a88ea7a4 100644 --- a/go.mod +++ b/go.mod @@ -11,10 +11,10 @@ require ( github.com/aliyun/aliyun-oss-go-sdk v2.2.9+incompatible github.com/anchore/syft v0.97.1 github.com/aquasecurity/trivy v0.47.0 - github.com/aws/aws-sdk-go v1.48.2 + github.com/aws/aws-sdk-go v1.48.3 github.com/bytedance/json v0.0.0-20190516032711-0d89175f1949 github.com/caarlos0/env/v9 v9.0.0 - github.com/casbin/casbin/v2 v2.77.2 + github.com/casbin/casbin/v2 v2.79.0 github.com/casbin/gorm-adapter/v3 v3.20.0 github.com/deckarep/golang-set/v2 v2.4.0 github.com/distribution/distribution/v3 v3.0.0-20231016181039-1d410148efe6 @@ -85,7 +85,6 @@ require ( dario.cat/mergo v1.0.0 // indirect github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20230306123547-8075edf89bb0 // indirect - github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect github.com/KyleBanks/depth v1.2.1 // indirect github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/semver/v3 v3.2.1 // indirect @@ -106,6 +105,7 @@ require ( github.com/aquasecurity/trivy-db v0.0.0-20231005141211-4fc651f7ac8d // indirect github.com/becheran/wildmatch-go v1.0.0 // indirect github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect + github.com/casbin/govaluate v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/clbanning/mxj v1.8.4 // indirect github.com/cloudflare/circl v1.3.3 // indirect @@ -294,7 +294,7 @@ require ( k8s.io/klog/v2 v2.100.1 // indirect k8s.io/kube-openapi v0.0.0-20230816210353-14e408962443 // indirect k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect - modernc.org/libc v1.29.0 // indirect + modernc.org/libc v1.34.9 // indirect modernc.org/mathutil v1.6.0 // indirect modernc.org/memory v1.7.2 // indirect modernc.org/sqlite v1.27.0 // indirect @@ -302,3 +302,5 @@ require ( sigs.k8s.io/structured-merge-diff/v4 v4.3.0 // indirect sigs.k8s.io/yaml v1.3.0 // indirect ) + +replace gorm.io/plugin/soft_delete => github.com/go-sigma/soft_delete v0.0.0-20231124084503-fb6a66078e2b diff --git a/go.sum b/go.sum index 2dd46589..21b5d1e8 100644 --- a/go.sum +++ b/go.sum @@ -72,8 +72,6 @@ github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3 github.com/DmitriyVTitov/size v1.5.0/go.mod h1:le6rNI4CoLQV1b9gzp1+3d7hMAD/uu2QcJ+aYbNgiU0= github.com/IBM/sarama v1.42.1 h1:wugyWa15TDEHh2kvq2gAy1IHLjEjuYOYgXz/ruC/OSQ= github.com/IBM/sarama v1.42.1/go.mod h1:Xxho9HkHd4K/MDUo/T/sOqwtX/17D33++E9Wib6hUdQ= -github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible h1:1G1pk05UrOh0NlF1oeaaix1x8XzrfjIDK47TY0Zehcw= -github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= @@ -147,8 +145,8 @@ github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= -github.com/aws/aws-sdk-go v1.48.2 h1:Lf7+Y4WmHB0AQLRQZA46diSwDa+LWbwY6IGaYoCVtTc= -github.com/aws/aws-sdk-go v1.48.2/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.48.3 h1:btYjT+opVFxUbRz+qSCjJe07cdX82BHmMX/FXYmoL7g= +github.com/aws/aws-sdk-go v1.48.3/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/becheran/wildmatch-go v1.0.0 h1:mE3dGGkTmpKtT4Z+88t8RStG40yN9T+kFEGj2PZFSzA= github.com/becheran/wildmatch-go v1.0.0/go.mod h1:gbMvj0NtVdJ15Mg/mH9uxk2R1QCistMyU7d9KFzroX4= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= @@ -168,10 +166,12 @@ github.com/bytedance/json v0.0.0-20190516032711-0d89175f1949 h1:JG8x1j2Jvu4e1Jwz github.com/bytedance/json v0.0.0-20190516032711-0d89175f1949/go.mod h1:sP1wlZn6XebMh0e4IPCNmVKCwQIXK4CDjUsQUbi0Ewo= github.com/caarlos0/env/v9 v9.0.0 h1:SI6JNsOA+y5gj9njpgybykATIylrRMklbs5ch6wO6pc= github.com/caarlos0/env/v9 v9.0.0/go.mod h1:ye5mlCVMYh6tZ+vCgrs/B95sj88cg5Tlnc0XIzgZ020= -github.com/casbin/casbin/v2 v2.77.2 h1:yQinn/w9x8AswiwqwtrXz93VU48R1aYTXdHEx4RI3jM= -github.com/casbin/casbin/v2 v2.77.2/go.mod h1:mzGx0hYW9/ksOSpw3wNjk3NRAroq5VMFYUQ6G43iGPk= +github.com/casbin/casbin/v2 v2.79.0 h1:6/Q1Ud/fiJ1S999Aa1vT3XqwhNKXvsa9Q3oeCnH0bUU= +github.com/casbin/casbin/v2 v2.79.0/go.mod h1:jX8uoN4veP85O/n2674r2qtfSXI6myvxW85f6TH50fw= github.com/casbin/gorm-adapter/v3 v3.20.0 h1:VpGKTlL56xIkhNUOC07bnzwjA/xqfVOAbkt6sniVxMo= github.com/casbin/gorm-adapter/v3 v3.20.0/go.mod h1:pvTTuyP2Es8VPHLyUssGtvOb3ETYD2tG7TfT5K8X2Sg= +github.com/casbin/govaluate v1.1.0 h1:6xdCWIpE9CwHdZhlVQW+froUrCsjb6/ZYNcXODfLT+E= +github.com/casbin/govaluate v1.1.0/go.mod h1:G/UnbIjZk/0uMNaLwZZmFQrR72tYRZWQkO70si/iR7A= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= @@ -377,6 +377,8 @@ github.com/go-redsync/redsync/v4 v4.11.0 h1:OPEcAxHBb95EzfwCKWM93ksOwHd5bTce2BD4 github.com/go-redsync/redsync/v4 v4.11.0/go.mod h1:ZfayzutkgeBmEmBlUR3j+rF6kN44UUGtEdfzhBFZTPc= github.com/go-resty/resty/v2 v2.10.0 h1:Qla4W/+TMmv0fOeeRqzEpXPLfTUnR5HZ1+lGs+CkiCo= github.com/go-resty/resty/v2 v2.10.0/go.mod h1:iiP/OpA0CkcL3IGt1O0+/SIItFUbkkyw5BGXiVdTu+A= +github.com/go-sigma/soft_delete v0.0.0-20231124084503-fb6a66078e2b h1:dP1itc+/9pJ/0ku3ntc8Rti0w+zuslJfOAnMNyv3N7I= +github.com/go-sigma/soft_delete v0.0.0-20231124084503-fb6a66078e2b/go.mod h1:Zv7vQctOJTGOsJ/bWgrN1n3od0GBAZgnLjEx+cApLGk= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI= @@ -998,7 +1000,6 @@ github.com/tencentyun/cos-go-sdk-v5 v0.7.45 h1:5/ZGOv846tP6+2X7w//8QjLgH2KcUK+Hc github.com/tencentyun/cos-go-sdk-v5 v0.7.45/go.mod h1:DH9US8nB+AJXqwu/AMOrCFN1COv3dpytXuJWHgdg7kE= github.com/therootcompany/xz v1.0.1 h1:CmOtsn1CbtmyYiusbfmhmkpAAETj0wBIH6kCYaX+xzw= github.com/therootcompany/xz v1.0.1/go.mod h1:3K3UH1yCKgBneZYhuQUvJ9HPD19UEXEI0BWbMn8qNMY= -github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/gjson v1.17.0 h1:/Jocvlh98kcTfpN2+JzGQWQcqrPQwDrVEMApx/M5ZwM= github.com/tidwall/gjson v1.17.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= @@ -1648,8 +1649,6 @@ gorm.io/hints v1.1.2 h1:b5j0kwk5p4+3BtDtYqqfY+ATSxjj+6ptPgVveuynn9o= gorm.io/hints v1.1.2/go.mod h1:/ARdpUHAtyEMCh5NNi3tI7FsGh+Cj/MIUlvNxCNCFWg= gorm.io/plugin/dbresolver v1.5.0 h1:XVHLxh775eP0CqVh3vcfJtYqja3uFl5Wr3cKlY8jgDY= gorm.io/plugin/dbresolver v1.5.0/go.mod h1:l4Cn87EHLEYuqUncpEeTC2tTJQkjngPSD+lo8hIvcT0= -gorm.io/plugin/soft_delete v1.2.1 h1:qx9D/c4Xu6w5KT8LviX8DgLcB9hkKl6JC9f44Tj7cGU= -gorm.io/plugin/soft_delete v1.2.1/go.mod h1:Zv7vQctOJTGOsJ/bWgrN1n3od0GBAZgnLjEx+cApLGk= gotest.tools/v3 v3.0.3 h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0= gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= @@ -1671,8 +1670,8 @@ k8s.io/kube-openapi v0.0.0-20230816210353-14e408962443 h1:CAIciCnJnSOQxPd0xvpV6J k8s.io/kube-openapi v0.0.0-20230816210353-14e408962443/go.mod h1:wZK2AVp1uHCp4VamDVgBP2COHZjqD1T68Rf0CM3YjSM= k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -modernc.org/libc v1.29.0 h1:tTFRFq69YKCF2QyGNuRUQxKBm1uZZLubf6Cjh/pVHXs= -modernc.org/libc v1.29.0/go.mod h1:DaG/4Q3LRRdqpiLyP0C2m1B8ZMGkQ+cCgOIjEtQlYhQ= +modernc.org/libc v1.34.9 h1:yhQGs5jsWHJIU7jY6nCe8GJw27j+z6xYi0eorwPpGgI= +modernc.org/libc v1.34.9/go.mod h1:YAXkAZ8ktnkCKaN9sw/UDeUVkGYJ/YquGO4FTi5nmHE= modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4= modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo= modernc.org/memory v1.7.2 h1:Klh90S215mmH8c9gO98QxQFsY+W451E8AnzjoE2ee1E= diff --git a/pkg/daemon/gc/gc_repository.go b/pkg/daemon/gc/gc_repository.go index dcf31a97..76b20c1a 100644 --- a/pkg/daemon/gc/gc_repository.go +++ b/pkg/daemon/gc/gc_repository.go @@ -175,9 +175,10 @@ func (g gcRepository) deleteRepositoryCheck() { log.Error().Err(err).Int64("RepositoryID", task.Repository.ID).Msg("Get repository by id failed") continue } - if !repositoryObj.UpdatedAt.Before(time.Now().Add(-1 * 24 * time.Duration(task.Runner.Rule.RetentionDay) * time.Hour)) { - continue - } + log.Info().Interface("repo", repositoryObj).Send() + // if !repositoryObj.UpdatedAt.Before(time.Now().Add(-1 * 24 * time.Duration(task.Runner.Rule.RetentionDay) * time.Hour)) { + // continue + // } } g.deleteRepositoryChan <- task } diff --git a/pkg/dal/dal.go b/pkg/dal/dal.go index decca53d..4ee4ea35 100644 --- a/pkg/dal/dal.go +++ b/pkg/dal/dal.go @@ -111,15 +111,6 @@ func Initialize() error { return nil } -// func connectRedis() error { -// redisOpt, err := redis.ParseURL(viper.GetString("redis.url")) -// if err != nil { -// return err -// } -// RedisCli = redis.NewClient(redisOpt) -// return nil -// } - func connectMysql() (string, error) { host := viper.GetString("database.mysql.host") port := viper.GetString("database.mysql.port") @@ -127,10 +118,13 @@ func connectMysql() (string, error) { password := viper.GetString("database.mysql.password") dbname := viper.GetString("database.mysql.dbname") - dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=True&loc=Local", user, password, host, port, dbname) + dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=True&loc=UTC", user, password, host, port, dbname) log.Debug().Str("dsn", dsn).Msg("Connect to mysql database") db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{ + NowFunc: func() time.Time { + return time.Now().UTC() + }, Logger: logger.ZLogger{}, }) if err != nil { @@ -152,6 +146,9 @@ func connectPostgres() (string, error) { dsn := fmt.Sprintf("host=%s port=%s user=%s dbname=%s password=%s sslmode=%s", host, port, user, dbname, password, sslmode) db, err := gorm.Open(postgres.Open(dsn), &gorm.Config{ + NowFunc: func() time.Time { + return time.Now().UTC() + }, Logger: logger.ZLogger{}, }) if err != nil { @@ -169,6 +166,9 @@ func connectSqlite3() (string, error) { dbname := viper.GetString("database.sqlite3.path") db, err := gorm.Open(sqlite.Open(dbname), &gorm.Config{ + NowFunc: func() time.Time { + return time.Now().UTC() + }, Logger: logger.ZLogger{}, }) if err != nil { diff --git a/pkg/dal/dao/artifact.go b/pkg/dal/dao/artifact.go index 2e141ebf..51c6f7f5 100644 --- a/pkg/dal/dao/artifact.go +++ b/pkg/dal/dao/artifact.go @@ -123,7 +123,7 @@ func (s *artifactService) Create(ctx context.Context, artifact *models.Artifact) func (s *artifactService) FindWithLastPull(ctx context.Context, repositoryID int64, before time.Time, limit, last int64) ([]*models.Artifact, error) { return s.tx.Artifact.WithContext(ctx). Where(s.tx.Artifact.LastPull.Lt(sql.NullTime{Valid: true, Time: before})). - Or(s.tx.Artifact.LastPull.IsNull(), s.tx.Artifact.UpdatedAt.Lt(before)). + Or(s.tx.Artifact.LastPull.IsNull(), s.tx.Artifact.UpdatedAt.Lt(before.UTC().UnixMilli())). Where(s.tx.Artifact.ID.Gt(last), s.tx.Artifact.RepositoryID.Eq(repositoryID)). Limit(int(limit)).Find() } diff --git a/pkg/dal/dao/blob.go b/pkg/dal/dao/blob.go index 20cbb8c6..860dd9a9 100644 --- a/pkg/dal/dao/blob.go +++ b/pkg/dal/dao/blob.go @@ -87,7 +87,7 @@ func (s *blobService) Create(ctx context.Context, blob *models.Blob) error { func (s *blobService) FindWithLastPull(ctx context.Context, before time.Time, last, limit int64) ([]*models.Blob, error) { return s.tx.Blob.WithContext(ctx). Where(s.tx.Blob.LastPull.Lt(sql.NullTime{Valid: true, Time: before})). - Or(s.tx.Blob.LastPull.IsNull(), s.tx.Blob.UpdatedAt.Lt(before)). + Or(s.tx.Blob.LastPull.IsNull(), s.tx.Blob.UpdatedAt.Lt(before.UTC().UnixMilli())). Where(s.tx.Blob.ID.Gt(last)).Find() } diff --git a/pkg/dal/dao/tag.go b/pkg/dal/dao/tag.go index 9335cc00..b618a173 100644 --- a/pkg/dal/dao/tag.go +++ b/pkg/dal/dao/tag.go @@ -161,7 +161,7 @@ func (s *tagService) FindWithQuantityCursor(ctx context.Context, repositoryID in func (s *tagService) FindWithDayCursor(ctx context.Context, repositoryID int64, day, limit int, last int64) ([]*models.Tag, error) { q := s.tx.Tag.WithContext(ctx).Where(s.tx.Tag.RepositoryID.Eq(repositoryID)).Order(s.tx.Tag.UpdatedAt.Desc()) if last == 0 { - q = q.Where(s.tx.Tag.UpdatedAt.Gt(time.Now().Add(time.Hour * 24 * time.Duration(day)))) + q = q.Where(s.tx.Tag.UpdatedAt.Gt(time.Now().Add(time.Hour * 24 * time.Duration(day)).UTC().UnixMilli())) } else { q = q.Where(s.tx.Tag.ID.Gt(last)) } diff --git a/pkg/dal/migrations/mysql/0001_initialize.up.sql b/pkg/dal/migrations/mysql/0001_initialize.up.sql index f40b2ed3..6bc53119 100644 --- a/pkg/dal/migrations/mysql/0001_initialize.up.sql +++ b/pkg/dal/migrations/mysql/0001_initialize.up.sql @@ -8,14 +8,16 @@ CREATE TABLE IF NOT EXISTS `users` ( `namespace_count` bigint NOT NULL DEFAULT 0, `status` ENUM ('Active', 'Inactive') NOT NULL DEFAULT 'Active', `role` ENUM ('Root', 'Admin', 'User') NOT NULL DEFAULT 'User', - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, UNIQUE KEY `users_unique_with_username` (`username`, `deleted_at`), - KEY `users_idx_created_at` (`created_at`), KEY `users_idx_status` (`status`), KEY `users_idx_role` (`role`), - KEY `users_idx_last_login` (`last_login`) + KEY `users_idx_last_login` (`last_login`), + KEY `users_idx_created_at` (`created_at`), + KEY `users_idx_updated_at` (`updated_at`), + KEY `users_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `user_3rdparty` ( @@ -28,11 +30,14 @@ CREATE TABLE IF NOT EXISTS `user_3rdparty` ( `cr_last_update_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `cr_last_update_status` ENUM ('Success', 'Failed', 'Doing') NOT NULL DEFAULT 'Doing', `cr_last_update_message` varchar(256), - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, FOREIGN KEY (`user_id`) REFERENCES `users` (`id`), - CONSTRAINT `user_3rdparty_unique_with_account_id` UNIQUE (`provider`, `account_id`, `deleted_at`) + CONSTRAINT `user_3rdparty_unique_with_account_id` UNIQUE (`provider`, `account_id`, `deleted_at`), + KEY `user_3rdparty_idx_created_at` (`created_at`), + KEY `user_3rdparty_idx_updated_at` (`updated_at`), + KEY `user_3rdparty_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `code_repository_clone_credentials` ( @@ -43,10 +48,13 @@ CREATE TABLE IF NOT EXISTS `code_repository_clone_credentials` ( `username` varchar(256), `password` varchar(256), `token` varchar(256), - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, - FOREIGN KEY (`user_3rdparty_id`) REFERENCES `user_3rdparty` (`id`) + FOREIGN KEY (`user_3rdparty_id`) REFERENCES `user_3rdparty` (`id`), + KEY `code_repository_clone_credentials_idx_created_at` (`created_at`), + KEY `code_repository_clone_credentials_idx_updated_at` (`updated_at`), + KEY `code_repository_clone_credentials_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `code_repository_owners` ( @@ -55,11 +63,14 @@ CREATE TABLE IF NOT EXISTS `code_repository_owners` ( `is_org` tinyint NOT NULL DEFAULT 0, `owner_id` varchar(256) NOT NULL, `owner` varchar(256) NOT NULL, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, FOREIGN KEY (`user_3rdparty_id`) REFERENCES `user_3rdparty` (`id`), - CONSTRAINT `code_repository_owners_unique_with_name` UNIQUE (`user_3rdparty_id`, `owner_id`, `deleted_at`) + CONSTRAINT `code_repository_owners_unique_with_name` UNIQUE (`user_3rdparty_id`, `owner_id`, `deleted_at`), + KEY `code_repository_owners_idx_created_at` (`created_at`), + KEY `code_repository_owners_idx_updated_at` (`updated_at`), + KEY `code_repository_owners_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `code_repositories` ( @@ -73,33 +84,42 @@ CREATE TABLE IF NOT EXISTS `code_repositories` ( `ssh_url` varchar(256) NOT NULL, `clone_url` varchar(256) NOT NULL, `oci_repo_count` bigint NOT NULL DEFAULT 0, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, FOREIGN KEY (`user_3rdparty_id`) REFERENCES `user_3rdparty` (`id`), - CONSTRAINT `code_repositories_unique_with_name` UNIQUE (`user_3rdparty_id`, `owner_id`, `repository_id`, `deleted_at`) + CONSTRAINT `code_repositories_unique_with_name` UNIQUE (`user_3rdparty_id`, `owner_id`, `repository_id`, `deleted_at`), + KEY `code_repositories_idx_created_at` (`created_at`), + KEY `code_repositories_idx_updated_at` (`updated_at`), + KEY `code_repositories_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `code_repository_branches` ( `id` bigint AUTO_INCREMENT PRIMARY KEY, `code_repository_id` bigint NOT NULL, `name` varchar(256) NOT NULL, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, FOREIGN KEY (`code_repository_id`) REFERENCES `code_repositories` (`id`), - CONSTRAINT `code_repository_branches_unique_with_name` UNIQUE (`code_repository_id`, `name`, `deleted_at`) + CONSTRAINT `code_repository_branches_unique_with_name` UNIQUE (`code_repository_id`, `name`, `deleted_at`), + KEY `code_repository_branches_idx_created_at` (`created_at`), + KEY `code_repository_branches_idx_updated_at` (`updated_at`), + KEY `code_repository_branches_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `user_recover_codes` ( `id` bigint AUTO_INCREMENT PRIMARY KEY, `user_id` bigint NOT NULL, `code` varchar(256) NOT NULL, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, FOREIGN KEY (`user_id`) REFERENCES `users` (`id`), - CONSTRAINT `user_recover_codes_unique_with_use_id` UNIQUE (`user_id`, `deleted_at`) + CONSTRAINT `user_recover_codes_unique_with_use_id` UNIQUE (`user_id`, `deleted_at`), + KEY `user_recover_codes_idx_created_at` (`created_at`), + KEY `user_recover_codes_idx_updated_at` (`updated_at`), + KEY `user_recover_codes_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `namespaces` ( @@ -113,10 +133,13 @@ CREATE TABLE IF NOT EXISTS `namespaces` ( `repository_count` bigint NOT NULL DEFAULT 0, `tag_limit` bigint NOT NULL DEFAULT 0, `tag_count` bigint NOT NULL DEFAULT 0, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, - CONSTRAINT `namespaces_unique_with_name` UNIQUE (`name`, `deleted_at`) + CONSTRAINT `namespaces_unique_with_name` UNIQUE (`name`, `deleted_at`), + KEY `namespaces_idx_created_at` (`created_at`), + KEY `namespaces_idx_updated_at` (`updated_at`), + KEY `namespaces_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `audits` ( @@ -128,11 +151,14 @@ CREATE TABLE IF NOT EXISTS `audits` ( `resource` varchar(256) NOT NULL, `before_raw` BLOB, `req_raw` BLOB, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, FOREIGN KEY (`user_id`) REFERENCES `users` (`id`), - FOREIGN KEY (`namespace_id`) REFERENCES `namespaces` (`id`) + FOREIGN KEY (`namespace_id`) REFERENCES `namespaces` (`id`), + KEY `audits_idx_created_at` (`created_at`), + KEY `audits_idx_updated_at` (`updated_at`), + KEY `audits_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `repositories` ( @@ -146,11 +172,14 @@ CREATE TABLE IF NOT EXISTS `repositories` ( `tag_limit` bigint NOT NULL DEFAULT 0, `tag_count` bigint NOT NULL DEFAULT 0, `namespace_id` bigint NOT NULL, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, FOREIGN KEY (`namespace_id`) REFERENCES `namespaces` (`id`), - CONSTRAINT `repositories_unique_with_namespace` UNIQUE (`namespace_id`, `name`, `deleted_at`) + CONSTRAINT `repositories_unique_with_namespace` UNIQUE (`namespace_id`, `name`, `deleted_at`), + KEY `repositories_idx_created_at` (`created_at`), + KEY `repositories_idx_updated_at` (`updated_at`), + KEY `repositories_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `artifacts` ( @@ -168,12 +197,15 @@ CREATE TABLE IF NOT EXISTS `artifacts` ( `last_pull` timestamp, `pull_times` bigint NOT NULL DEFAULT 0, `referrer_id` bigint, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, FOREIGN KEY (`repository_id`) REFERENCES `repositories` (`id`), FOREIGN KEY (`referrer_id`) REFERENCES `artifacts` (`id`), - CONSTRAINT `artifacts_unique_with_repo` UNIQUE (`repository_id`, `digest`, `deleted_at`) + CONSTRAINT `artifacts_unique_with_repo` UNIQUE (`repository_id`, `digest`, `deleted_at`), + KEY `artifacts_idx_created_at` (`created_at`), + KEY `artifacts_idx_updated_at` (`updated_at`), + KEY `artifacts_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `artifact_sboms` ( @@ -185,11 +217,14 @@ CREATE TABLE IF NOT EXISTS `artifact_sboms` ( `stdout` MEDIUMBLOB, `stderr` MEDIUMBLOB, `message` varchar(256), - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, FOREIGN KEY (`artifact_id`) REFERENCES `artifacts` (`id`), - CONSTRAINT `artifact_sbom_unique_with_artifact` UNIQUE (`artifact_id`, `deleted_at`) + CONSTRAINT `artifact_sbom_unique_with_artifact` UNIQUE (`artifact_id`, `deleted_at`), + KEY `artifact_sboms_idx_created_at` (`created_at`), + KEY `artifact_sboms_idx_updated_at` (`updated_at`), + KEY `artifact_sboms_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `artifact_vulnerabilities` ( @@ -202,11 +237,14 @@ CREATE TABLE IF NOT EXISTS `artifact_vulnerabilities` ( `stdout` MEDIUMBLOB, `stderr` MEDIUMBLOB, `message` varchar(256), - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, FOREIGN KEY (`artifact_id`) REFERENCES `artifacts` (`id`), - CONSTRAINT `artifact_vulnerability_unique_with_artifact` UNIQUE (`artifact_id`, `deleted_at`) + CONSTRAINT `artifact_vulnerability_unique_with_artifact` UNIQUE (`artifact_id`, `deleted_at`), + KEY `artifact_vulnerabilities_sboms_idx_created_at` (`created_at`), + KEY `artifact_vulnerabilities_sboms_idx_updated_at` (`updated_at`), + KEY `artifact_vulnerabilities_sboms_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `tags` ( @@ -217,12 +255,15 @@ CREATE TABLE IF NOT EXISTS `tags` ( `pushed_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `last_pull` timestamp, `pull_times` bigint NOT NULL DEFAULT 0, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, FOREIGN KEY (`repository_id`) REFERENCES `repositories` (`id`), FOREIGN KEY (`artifact_id`) REFERENCES `artifacts` (`id`), - CONSTRAINT `tags_unique_with_repo` UNIQUE (`repository_id`, `name`, `deleted_at`) + CONSTRAINT `tags_unique_with_repo` UNIQUE (`repository_id`, `name`, `deleted_at`), + KEY `tags_idx_created_at` (`created_at`), + KEY `tags_idx_updated_at` (`updated_at`), + KEY `tags_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `blobs` ( @@ -233,10 +274,13 @@ CREATE TABLE IF NOT EXISTS `blobs` ( `pushed_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `last_pull` timestamp, `pull_times` bigint NOT NULL DEFAULT 0, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, - CONSTRAINT `blobs_unique_with_digest` UNIQUE (`digest`, `deleted_at`) + CONSTRAINT `blobs_unique_with_digest` UNIQUE (`digest`, `deleted_at`), + KEY `blobs_idx_created_at` (`created_at`), + KEY `blobs_idx_updated_at` (`updated_at`), + KEY `blobs_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `blob_uploads` ( @@ -247,10 +291,13 @@ CREATE TABLE IF NOT EXISTS `blob_uploads` ( `repository` varchar(256) NOT NULL, `file_id` varchar(256) NOT NULL, `size` bigint NOT NULL DEFAULT 0, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, - CONSTRAINT `blob_uploads_unique_with_upload_id_etag` UNIQUE (`upload_id`, `etag`, `deleted_at`) + CONSTRAINT `blob_uploads_unique_with_upload_id_etag` UNIQUE (`upload_id`, `etag`, `deleted_at`), + KEY `blob_uploads_idx_created_at` (`created_at`), + KEY `blob_uploads_idx_updated_at` (`updated_at`), + KEY `blob_uploads_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `artifact_artifacts` ( @@ -279,11 +326,14 @@ CREATE TABLE IF NOT EXISTS `daemon_gc_tag_rules` ( `retention_rule_type` ENUM ('Day', 'Quantity') NOT NULL DEFAULT 'Quantity', `retention_rule_amount` bigint NOT NULL DEFAULT 1, `retention_pattern` varchar(64), - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, FOREIGN KEY (`namespace_id`) REFERENCES `namespaces` (`id`), - CONSTRAINT `daemon_gc_tag_rules_unique_with_ns` UNIQUE (`namespace_id`, `deleted_at`) + CONSTRAINT `daemon_gc_tag_rules_unique_with_ns` UNIQUE (`namespace_id`, `deleted_at`), + KEY `daemon_gc_tag_rules_idx_created_at` (`created_at`), + KEY `daemon_gc_tag_rules_idx_updated_at` (`updated_at`), + KEY `daemon_gc_tag_rules_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `daemon_gc_tag_runners` ( @@ -296,10 +346,13 @@ CREATE TABLE IF NOT EXISTS `daemon_gc_tag_runners` ( `duration` bigint, `success_count` bigint, `failed_count` bigint, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, - FOREIGN KEY (`rule_id`) REFERENCES `daemon_gc_tag_rules` (`id`) + FOREIGN KEY (`rule_id`) REFERENCES `daemon_gc_tag_rules` (`id`), + KEY `daemon_gc_tag_runners_idx_created_at` (`created_at`), + KEY `daemon_gc_tag_runners_idx_updated_at` (`updated_at`), + KEY `daemon_gc_tag_runners_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `daemon_gc_tag_records` ( @@ -308,10 +361,13 @@ CREATE TABLE IF NOT EXISTS `daemon_gc_tag_records` ( `tag` varchar(128) NOT NULL, `status` ENUM ('Success', 'Failed') NOT NULL DEFAULT 'Success', `message` LONGBLOB, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, - FOREIGN KEY (`runner_id`) REFERENCES `daemon_gc_tag_runners` (`id`) + FOREIGN KEY (`runner_id`) REFERENCES `daemon_gc_tag_runners` (`id`), + KEY `daemon_gc_tag_records_idx_created_at` (`created_at`), + KEY `daemon_gc_tag_records_idx_updated_at` (`updated_at`), + KEY `daemon_gc_tag_records_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `daemon_gc_repository_rules` ( @@ -322,11 +378,14 @@ CREATE TABLE IF NOT EXISTS `daemon_gc_repository_rules` ( `cron_enabled` tinyint NOT NULL DEFAULT 0, `cron_rule` varchar(30), `cron_next_trigger` timestamp, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, FOREIGN KEY (`namespace_id`) REFERENCES `namespaces` (`id`), - CONSTRAINT `daemon_gc_repository_rules_unique_with_ns` UNIQUE (`namespace_id`, `deleted_at`) + CONSTRAINT `daemon_gc_repository_rules_unique_with_ns` UNIQUE (`namespace_id`, `deleted_at`), + KEY `daemon_gc_repository_rules_idx_created_at` (`created_at`), + KEY `daemon_gc_repository_rules_idx_updated_at` (`updated_at`), + KEY `daemon_gc_repository_rules_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `daemon_gc_repository_runners` ( @@ -339,10 +398,13 @@ CREATE TABLE IF NOT EXISTS `daemon_gc_repository_runners` ( `duration` bigint, `success_count` bigint, `failed_count` bigint, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, - FOREIGN KEY (`rule_id`) REFERENCES `daemon_gc_repository_rules` (`id`) + FOREIGN KEY (`rule_id`) REFERENCES `daemon_gc_repository_rules` (`id`), + KEY `daemon_gc_repository_runners_idx_created_at` (`created_at`), + KEY `daemon_gc_repository_runners_idx_updated_at` (`updated_at`), + KEY `daemon_gc_repository_runners_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `daemon_gc_repository_records` ( @@ -351,10 +413,13 @@ CREATE TABLE IF NOT EXISTS `daemon_gc_repository_records` ( `repository` varchar(64) NOT NULL, `status` ENUM ('Success', 'Failed') NOT NULL DEFAULT 'Success', `message` LONGBLOB, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, - FOREIGN KEY (`runner_id`) REFERENCES `daemon_gc_repository_runners` (`id`) + FOREIGN KEY (`runner_id`) REFERENCES `daemon_gc_repository_runners` (`id`), + KEY `daemon_gc_repository_records_idx_created_at` (`created_at`), + KEY `daemon_gc_repository_records_idx_updated_at` (`updated_at`), + KEY `daemon_gc_repository_records_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `daemon_gc_artifact_rules` ( @@ -365,11 +430,14 @@ CREATE TABLE IF NOT EXISTS `daemon_gc_artifact_rules` ( `cron_enabled` tinyint NOT NULL DEFAULT 0, `cron_rule` varchar(30), `cron_next_trigger` timestamp, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, FOREIGN KEY (`namespace_id`) REFERENCES `namespaces` (`id`), - CONSTRAINT `daemon_gc_artifact_rules_unique_with_ns` UNIQUE (`namespace_id`, `deleted_at`) + CONSTRAINT `daemon_gc_artifact_rules_unique_with_ns` UNIQUE (`namespace_id`, `deleted_at`), + KEY `daemon_gc_artifact_rules_idx_created_at` (`created_at`), + KEY `daemon_gc_artifact_rules_idx_updated_at` (`updated_at`), + KEY `daemon_gc_artifact_rules_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `daemon_gc_artifact_runners` ( @@ -382,10 +450,13 @@ CREATE TABLE IF NOT EXISTS `daemon_gc_artifact_runners` ( `duration` bigint, `success_count` bigint, `failed_count` bigint, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, - FOREIGN KEY (`rule_id`) REFERENCES `daemon_gc_artifact_rules` (`id`) + FOREIGN KEY (`rule_id`) REFERENCES `daemon_gc_artifact_rules` (`id`), + KEY `daemon_gc_artifact_runners_idx_created_at` (`created_at`), + KEY `daemon_gc_artifact_runners_idx_updated_at` (`updated_at`), + KEY `daemon_gc_artifact_runners_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `daemon_gc_artifact_records` ( @@ -394,10 +465,13 @@ CREATE TABLE IF NOT EXISTS `daemon_gc_artifact_records` ( `digest` varchar(256) NOT NULL, `status` ENUM ('Success', 'Failed') NOT NULL DEFAULT 'Success', `message` LONGBLOB, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, - FOREIGN KEY (`runner_id`) REFERENCES `daemon_gc_artifact_runners` (`id`) + FOREIGN KEY (`runner_id`) REFERENCES `daemon_gc_artifact_runners` (`id`), + KEY `daemon_gc_artifact_records_idx_created_at` (`created_at`), + KEY `daemon_gc_artifact_records_idx_updated_at` (`updated_at`), + KEY `daemon_gc_artifact_records_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `daemon_gc_blob_rules` ( @@ -407,9 +481,12 @@ CREATE TABLE IF NOT EXISTS `daemon_gc_blob_rules` ( `cron_enabled` tinyint NOT NULL DEFAULT 0, `cron_rule` varchar(30), `cron_next_trigger` timestamp, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `deleted_at` bigint NOT NULL DEFAULT 0 + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `deleted_at` bigint NOT NULL DEFAULT 0, + KEY `daemon_gc_blob_rules_idx_created_at` (`created_at`), + KEY `daemon_gc_blob_rules_idx_updated_at` (`updated_at`), + KEY `daemon_gc_blob_rules_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `daemon_gc_blob_runners` ( @@ -422,10 +499,13 @@ CREATE TABLE IF NOT EXISTS `daemon_gc_blob_runners` ( `duration` bigint, `success_count` bigint, `failed_count` bigint, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, - FOREIGN KEY (`rule_id`) REFERENCES `daemon_gc_blob_rules` (`id`) + FOREIGN KEY (`rule_id`) REFERENCES `daemon_gc_blob_rules` (`id`), + KEY `daemon_gc_blob_runners_idx_created_at` (`created_at`), + KEY `daemon_gc_blob_runners_idx_updated_at` (`updated_at`), + KEY `daemon_gc_blob_runners_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `daemon_gc_blob_records` ( @@ -434,10 +514,13 @@ CREATE TABLE IF NOT EXISTS `daemon_gc_blob_records` ( `digest` varchar(256) NOT NULL, `status` ENUM ('Success', 'Failed') NOT NULL DEFAULT 'Success', `message` LONGBLOB, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, - FOREIGN KEY (`runner_id`) REFERENCES `daemon_gc_repository_runners` (`id`) + FOREIGN KEY (`runner_id`) REFERENCES `daemon_gc_repository_runners` (`id`), + KEY `daemon_gc_blob_records_idx_created_at` (`created_at`), + KEY `daemon_gc_blob_records_idx_updated_at` (`updated_at`), + KEY `daemon_gc_blob_records_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `casbin_rules` ( @@ -457,11 +540,14 @@ CREATE TABLE IF NOT EXISTS `namespace_members` ( `user_id` bigint NOT NULL, `namespace_id` bigint NOT NULL, `role` ENUM ('NamespaceReader', 'NamespaceManager', 'NamespaceAdmin') NOT NULL DEFAULT 'NamespaceReader', - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, FOREIGN KEY (`user_id`) REFERENCES `users` (`id`), - CONSTRAINT `namespace_members_unique_with_user_ns_role` UNIQUE (`user_id`, `namespace_id`, `role`, `deleted_at`) + CONSTRAINT `namespace_members_unique_with_user_ns_role` UNIQUE (`user_id`, `namespace_id`, `role`, `deleted_at`), + KEY `namespace_members_idx_created_at` (`created_at`), + KEY `namespace_members_idx_updated_at` (`updated_at`), + KEY `namespace_members_idx_deleted_at` (`deleted_at`) ); -- ptype type @@ -503,9 +589,12 @@ CREATE TABLE IF NOT EXISTS `webhooks` ( `event_tag` tinyint NOT NULL DEFAULT 1, `event_pull_push` tinyint NOT NULL DEFAULT 1, `event_member` tinyint NOT NULL DEFAULT 1, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `deleted_at` bigint NOT NULL DEFAULT 0 + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `deleted_at` bigint NOT NULL DEFAULT 0, + KEY `webhooks_idx_created_at` (`created_at`), + KEY `webhooks_idx_updated_at` (`updated_at`), + KEY `webhooks_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `webhook_logs` ( @@ -517,10 +606,13 @@ CREATE TABLE IF NOT EXISTS `webhook_logs` ( `req_body` BLOB NOT NULL, `resp_header` BLOB NOT NULL, `resp_body` BLOB, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, - FOREIGN KEY (`webhook_id`) REFERENCES `webhooks` (`id`) + FOREIGN KEY (`webhook_id`) REFERENCES `webhooks` (`id`), + KEY `webhook_logs_idx_created_at` (`created_at`), + KEY `webhook_logs_idx_updated_at` (`updated_at`), + KEY `webhook_logs_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `builders` ( @@ -558,12 +650,15 @@ CREATE TABLE IF NOT EXISTS `builders` ( `buildkit_platforms` varchar(256) NOT NULL DEFAULT 'linux/amd64', `buildkit_build_args` varchar(256), -- other fields - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, FOREIGN KEY (`repository_id`) REFERENCES `repositories` (`id`), FOREIGN KEY (`code_repository_id`) REFERENCES `code_repositories` (`id`), - CONSTRAINT `builders_unique_with_repository` UNIQUE (`repository_id`, `deleted_at`) + CONSTRAINT `builders_unique_with_repository` UNIQUE (`repository_id`, `deleted_at`), + KEY `builders_idx_created_at` (`created_at`), + KEY `builders_idx_updated_at` (`updated_at`), + KEY `builders_idx_deleted_at` (`deleted_at`) ); -- TODO: buildx flags @@ -581,10 +676,13 @@ CREATE TABLE IF NOT EXISTS `builder_runners` ( `ended_at` timestamp, `duration` bigint, -- other fields - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, - FOREIGN KEY (`builder_id`) REFERENCES `builders` (`id`) + FOREIGN KEY (`builder_id`) REFERENCES `builders` (`id`), + KEY `builder_runners_idx_created_at` (`created_at`), + KEY `builder_runners_idx_updated_at` (`updated_at`), + KEY `builder_runners_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `work_queues` ( @@ -594,18 +692,24 @@ CREATE TABLE IF NOT EXISTS `work_queues` ( `times` MEDIUMINT NOT NULL DEFAULT 0, `version` varchar(36) NOT NULL, `status` ENUM ('Success', 'Failed', 'Pending', 'Doing') NOT NULL DEFAULT 'Pending', - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `deleted_at` bigint NOT NULL DEFAULT 0 + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `deleted_at` bigint NOT NULL DEFAULT 0, + KEY `work_queues_idx_created_at` (`created_at`), + KEY `work_queues_idx_updated_at` (`updated_at`), + KEY `work_queues_idx_deleted_at` (`deleted_at`) ); CREATE TABLE IF NOT EXISTS `caches` ( `id` bigint AUTO_INCREMENT PRIMARY KEY, `key` varchar(256) NOT NULL UNIQUE, `val` BLOB NOT NULL, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `deleted_at` bigint NOT NULL DEFAULT 0 + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `deleted_at` bigint NOT NULL DEFAULT 0, + KEY `caches_idx_created_at` (`created_at`), + KEY `caches_idx_updated_at` (`updated_at`), + KEY `caches_idx_deleted_at` (`deleted_at`) ); CREATE INDEX `idx_created_at` ON `caches` (`created_at`); @@ -614,8 +718,11 @@ CREATE TABLE IF NOT EXISTS `settings` ( `id` bigint AUTO_INCREMENT PRIMARY KEY, `key` varchar(256) NOT NULL UNIQUE, `val` BLOB, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `deleted_at` bigint NOT NULL DEFAULT 0 + `created_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `updated_at` bigint NOT NULL DEFAULT (UNIX_TIMESTAMP (CURRENT_TIMESTAMP()) * 1000), + `deleted_at` bigint NOT NULL DEFAULT 0, + KEY `settings_idx_created_at` (`created_at`), + KEY `settings_idx_updated_at` (`updated_at`), + KEY `settings_idx_deleted_at` (`deleted_at`) ); diff --git a/pkg/dal/migrations/postgresql/0001_initialize.up.sql b/pkg/dal/migrations/postgresql/0001_initialize.up.sql index f55e9b93..7108d776 100644 --- a/pkg/dal/migrations/postgresql/0001_initialize.up.sql +++ b/pkg/dal/migrations/postgresql/0001_initialize.up.sql @@ -32,14 +32,18 @@ CREATE TABLE IF NOT EXISTS "users" ( "namespace_count" bigint NOT NULL DEFAULT 0, "status" user_status NOT NULL DEFAULT 'Active', "role" user_role NOT NULL DEFAULT 'User', - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" bigint NOT NULL DEFAULT 0, CONSTRAINT "users_unique_with_username" UNIQUE ("username", "deleted_at") ); CREATE INDEX "users_idx_created_at" ON "users" ("created_at"); +CREATE INDEX "users_idx_updated_at" ON "users" ("updated_at"); + +CREATE INDEX "users_idx_deleted_at" ON "users" ("deleted_at"); + CREATE INDEX "users_idx_status" ON "users" ("status"); CREATE INDEX "users_idx_role" ON "users" ("role"); @@ -56,13 +60,19 @@ CREATE TABLE IF NOT EXISTS "user_3rdparty" ( "cr_last_update_timestamp" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "cr_last_update_status" daemon_status NOT NULL DEFAULT 'Doing', "cr_last_update_message" varchar(256), - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" bigint NOT NULL DEFAULT 0, FOREIGN KEY ("user_id") REFERENCES "users" ("id"), CONSTRAINT "user_3rdparty_unique_with_account_id" UNIQUE ("provider", "account_id", "deleted_at") ); +CREATE INDEX "user_3rdparty_idx_created_at" ON "user_3rdparty" ("created_at"); + +CREATE INDEX "user_3rdparty_idx_updated_at" ON "user_3rdparty" ("updated_at"); + +CREATE INDEX "user_3rdparty_idx_deleted_at" ON "user_3rdparty" ("deleted_at"); + CREATE TYPE code_repository_clone_credentials_type AS enum ( 'none', 'ssh', @@ -78,25 +88,37 @@ CREATE TABLE IF NOT EXISTS "code_repository_clone_credentials" ( "username" varchar(256), "password" varchar(256), "token" varchar(256), - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" bigint NOT NULL DEFAULT 0, FOREIGN KEY ("user_3rdparty_id") REFERENCES "user_3rdparty" ("id") ); +CREATE INDEX "code_repository_clone_credentials_idx_created_at" ON "code_repository_clone_credentials" ("created_at"); + +CREATE INDEX "code_repository_clone_credentials_idx_updated_at" ON "code_repository_clone_credentials" ("updated_at"); + +CREATE INDEX "code_repository_clone_credentials_idx_deleted_at" ON "code_repository_clone_credentials" ("deleted_at"); + CREATE TABLE IF NOT EXISTS "code_repository_owners" ( "id" bigserial PRIMARY KEY, "user_3rdparty_id" bigint NOT NULL, "is_org" smallint NOT NULL DEFAULT 0, "owner_id" varchar(256) NOT NULL, "owner" varchar(256) NOT NULL, - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" bigint NOT NULL DEFAULT 0, FOREIGN KEY ("user_3rdparty_id") REFERENCES "user_3rdparty" ("id"), CONSTRAINT "code_repository_owners_unique_with_name" UNIQUE ("user_3rdparty_id", "owner_id", "deleted_at") ); +CREATE INDEX "code_repository_owners_idx_created_at" ON "code_repository_owners" ("created_at"); + +CREATE INDEX "code_repository_owners_idx_updated_at" ON "code_repository_owners" ("updated_at"); + +CREATE INDEX "code_repository_owners_idx_deleted_at" ON "code_repository_owners" ("deleted_at"); + CREATE TABLE IF NOT EXISTS "code_repositories" ( "id" bigserial PRIMARY KEY, "user_3rdparty_id" bigint NOT NULL, @@ -108,35 +130,53 @@ CREATE TABLE IF NOT EXISTS "code_repositories" ( "ssh_url" varchar(256) NOT NULL, "clone_url" varchar(256) NOT NULL, "oci_repo_count" bigint NOT NULL DEFAULT 0, - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" bigint NOT NULL DEFAULT 0, FOREIGN KEY ("user_3rdparty_id") REFERENCES "user_3rdparty" ("id"), CONSTRAINT "code_repositories_unique_with_name" UNIQUE ("user_3rdparty_id", "owner_id", "repository_id", "deleted_at") ); +CREATE INDEX "code_repositories_idx_created_at" ON "code_repositories" ("created_at"); + +CREATE INDEX "code_repositories_idx_updated_at" ON "code_repositories" ("updated_at"); + +CREATE INDEX "code_repositories_idx_deleted_at" ON "code_repositories" ("deleted_at"); + CREATE TABLE IF NOT EXISTS "code_repository_branches" ( "id" bigserial PRIMARY KEY, "code_repository_id" integer NOT NULL, "name" varchar(256) NOT NULL, - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" integer NOT NULL DEFAULT 0, FOREIGN KEY ("code_repository_id") REFERENCES "code_repositories" ("id"), CONSTRAINT "code_repository_branches_unique_with_name" UNIQUE ("code_repository_id", "name", "deleted_at") ); +CREATE INDEX "code_repository_branches_idx_created_at" ON "code_repository_branches" ("created_at"); + +CREATE INDEX "code_repository_branches_idx_updated_at" ON "code_repository_branches" ("updated_at"); + +CREATE INDEX "code_repository_branches_idx_deleted_at" ON "code_repository_branches" ("deleted_at"); + CREATE TABLE IF NOT EXISTS "user_recover_codes" ( "id" bigserial PRIMARY KEY, "user_id" bigint NOT NULL, "code" varchar(256) NOT NULL, - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" integer NOT NULL DEFAULT 0, FOREIGN KEY ("user_id") REFERENCES "users" ("id"), CONSTRAINT "user_recover_codes_unique_with_user_id" UNIQUE ("user_id", "deleted_at") ); +CREATE INDEX "user_recover_codes_idx_created_at" ON "user_recover_codes" ("created_at"); + +CREATE INDEX "user_recover_codes_idx_updated_at" ON "user_recover_codes" ("updated_at"); + +CREATE INDEX "user_recover_codes_idx_deleted_at" ON "user_recover_codes" ("deleted_at"); + CREATE TYPE visibility AS ENUM ( 'public', 'private' @@ -153,12 +193,18 @@ CREATE TABLE IF NOT EXISTS "namespaces" ( "repository_count" bigint NOT NULL DEFAULT 0, "tag_limit" bigint NOT NULL DEFAULT 0, "tag_count" bigint NOT NULL DEFAULT 0, - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" bigint NOT NULL DEFAULT 0, CONSTRAINT "namespaces_unique_with_name" UNIQUE ("name", "deleted_at") ); +CREATE INDEX "namespaces_idx_created_at" ON "namespaces" ("created_at"); + +CREATE INDEX "namespaces_idx_updated_at" ON "namespaces" ("updated_at"); + +CREATE INDEX "namespaces_idx_deleted_at" ON "namespaces" ("deleted_at"); + CREATE TYPE audit_action AS ENUM ( 'Create', 'Update', @@ -183,13 +229,19 @@ CREATE TABLE IF NOT EXISTS "audits" ( "resource" varchar(256) NOT NULL, "before_raw" bytea, "req_raw" bytea, - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" bigint NOT NULL DEFAULT 0, FOREIGN KEY ("user_id") REFERENCES "users" ("id"), FOREIGN KEY ("namespace_id") REFERENCES "namespaces" ("id") ); +CREATE INDEX "audits_idx_created_at" ON "audits" ("created_at"); + +CREATE INDEX "audits_idx_updated_at" ON "audits" ("updated_at"); + +CREATE INDEX "audits_idx_deleted_at" ON "audits" ("deleted_at"); + CREATE TABLE IF NOT EXISTS "repositories" ( "id" bigserial PRIMARY KEY, "name" varchar(64) NOT NULL, @@ -201,13 +253,19 @@ CREATE TABLE IF NOT EXISTS "repositories" ( "tag_limit" bigint NOT NULL DEFAULT 0, "tag_count" bigint NOT NULL DEFAULT 0, "namespace_id" bigserial NOT NULL, - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" bigint NOT NULL DEFAULT 0, FOREIGN KEY ("namespace_id") REFERENCES "namespaces" ("id"), CONSTRAINT "repositories_unique_with_namespace" UNIQUE ("namespace_id", "name", "deleted_at") ); +CREATE INDEX "repositories_idx_created_at" ON "repositories" ("created_at"); + +CREATE INDEX "repositories_idx_updated_at" ON "repositories" ("updated_at"); + +CREATE INDEX "repositories_idx_deleted_at" ON "repositories" ("deleted_at"); + CREATE TYPE artifact_type AS ENUM ( 'Image', 'ImageIndex', @@ -234,14 +292,20 @@ CREATE TABLE IF NOT EXISTS "artifacts" ( "last_pull" timestamp, "pull_times" bigint NOT NULL DEFAULT 0, "referrer_id" bigint, - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" bigint NOT NULL DEFAULT 0, FOREIGN KEY ("repository_id") REFERENCES "repositories" ("id"), FOREIGN KEY ("referrer_id") REFERENCES "artifacts" ("id"), CONSTRAINT "artifacts_unique_with_repo" UNIQUE ("repository_id", "digest", "deleted_at") ); +CREATE INDEX "artifacts_idx_created_at" ON "artifacts" ("created_at"); + +CREATE INDEX "artifacts_idx_updated_at" ON "artifacts" ("updated_at"); + +CREATE INDEX "artifacts_idx_deleted_at" ON "artifacts" ("deleted_at"); + CREATE TABLE IF NOT EXISTS "artifact_sboms" ( "id" bigserial PRIMARY KEY, "artifact_id" bigint NOT NULL, @@ -251,13 +315,19 @@ CREATE TABLE IF NOT EXISTS "artifact_sboms" ( "stdout" bytea, "stderr" bytea, "message" varchar(256), - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" bigint NOT NULL DEFAULT 0, FOREIGN KEY ("artifact_id") REFERENCES "artifacts" ("id"), CONSTRAINT "artifact_sbom_unique_with_artifact" UNIQUE ("artifact_id", "deleted_at") ); +CREATE INDEX "artifact_sboms_idx_created_at" ON "artifact_sboms" ("created_at"); + +CREATE INDEX "artifact_sboms_idx_updated_at" ON "artifact_sboms" ("updated_at"); + +CREATE INDEX "artifact_sboms_idx_deleted_at" ON "artifact_sboms" ("deleted_at"); + CREATE TABLE IF NOT EXISTS "artifact_vulnerabilities" ( "id" bigserial PRIMARY KEY, "artifact_id" bigint NOT NULL, @@ -268,13 +338,19 @@ CREATE TABLE IF NOT EXISTS "artifact_vulnerabilities" ( "stdout" bytea, "stderr" bytea, "message" varchar(256), - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" bigint NOT NULL DEFAULT 0, FOREIGN KEY ("artifact_id") REFERENCES "artifacts" ("id"), CONSTRAINT "artifact_vulnerability_unique_with_artifact" UNIQUE ("artifact_id", "deleted_at") ); +CREATE INDEX "artifact_vulnerabilities_idx_created_at" ON "artifact_vulnerabilities" ("created_at"); + +CREATE INDEX "artifact_vulnerabilities_idx_updated_at" ON "artifact_vulnerabilities" ("updated_at"); + +CREATE INDEX "artifact_vulnerabilities_idx_deleted_at" ON "artifact_vulnerabilities" ("deleted_at"); + CREATE TABLE IF NOT EXISTS "tags" ( "id" bigserial PRIMARY KEY, "repository_id" bigint NOT NULL, @@ -283,14 +359,20 @@ CREATE TABLE IF NOT EXISTS "tags" ( "pushed_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "last_pull" timestamp, "pull_times" bigint NOT NULL DEFAULT 0, - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" bigint NOT NULL DEFAULT 0, FOREIGN KEY ("repository_id") REFERENCES "repositories" ("id"), FOREIGN KEY ("artifact_id") REFERENCES "artifacts" ("id"), CONSTRAINT "tags_unique_with_repo" UNIQUE ("repository_id", "name", "deleted_at") ); +CREATE INDEX "tags_idx_created_at" ON "tags" ("created_at"); + +CREATE INDEX "tags_idx_updated_at" ON "tags" ("updated_at"); + +CREATE INDEX "tags_idx_deleted_at" ON "tags" ("deleted_at"); + CREATE TABLE IF NOT EXISTS "blobs" ( "id" bigserial PRIMARY KEY, "digest" varchar(256) NOT NULL UNIQUE, @@ -299,12 +381,18 @@ CREATE TABLE IF NOT EXISTS "blobs" ( "pushed_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "last_pull" timestamp, "pull_times" bigint NOT NULL DEFAULT 0, - "created_at" timestamp NOT NULL, - "updated_at" timestamp NOT NULL, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" bigint NOT NULL DEFAULT 0, CONSTRAINT "blobs_unique_with_digest" UNIQUE ("digest", "deleted_at") ); +CREATE INDEX "blobs_idx_created_at" ON "blobs" ("created_at"); + +CREATE INDEX "blobs_idx_updated_at" ON "blobs" ("updated_at"); + +CREATE INDEX "blobs_idx_deleted_at" ON "blobs" ("deleted_at"); + CREATE TABLE IF NOT EXISTS "blob_uploads" ( "id" bigserial PRIMARY KEY, "part_number" int NOT NULL, @@ -313,12 +401,18 @@ CREATE TABLE IF NOT EXISTS "blob_uploads" ( "repository" varchar(256) NOT NULL, "file_id" varchar(256) NOT NULL, "size" bigint NOT NULL DEFAULT 0, - "created_at" timestamp NOT NULL, - "updated_at" timestamp NOT NULL, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" bigint NOT NULL DEFAULT 0, CONSTRAINT "blob_uploads_unique_with_upload_id_etag" UNIQUE ("upload_id", "etag", "deleted_at") ); +CREATE INDEX "blob_uploads_idx_created_at" ON "blob_uploads" ("created_at"); + +CREATE INDEX "blob_uploads_idx_updated_at" ON "blob_uploads" ("updated_at"); + +CREATE INDEX "blob_uploads_idx_deleted_at" ON "blob_uploads" ("deleted_at"); + CREATE TABLE IF NOT EXISTS "artifact_artifacts" ( "artifact_id" bigint NOT NULL, "artifact_index_id" bigint NOT NULL, @@ -350,13 +444,19 @@ CREATE TABLE IF NOT EXISTS "daemon_gc_tag_rules" ( "retention_rule_type" retention_rule_type NOT NULL DEFAULT 'Quantity', "retention_rule_amount" bigint NOT NULL DEFAULT 1, "retention_pattern" varchar(64), - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" bigint NOT NULL DEFAULT 0, FOREIGN KEY ("namespace_id") REFERENCES "namespaces" ("id"), CONSTRAINT "daemon_gc_tag_rules_unique_with_ns" UNIQUE ("namespace_id", "deleted_at") ); +CREATE INDEX "daemon_gc_tag_rules_idx_created_at" ON "daemon_gc_tag_rules" ("created_at"); + +CREATE INDEX "daemon_gc_tag_rules_idx_updated_at" ON "daemon_gc_tag_rules" ("updated_at"); + +CREATE INDEX "daemon_gc_tag_rules_idx_deleted_at" ON "daemon_gc_tag_rules" ("deleted_at"); + CREATE TABLE IF NOT EXISTS "daemon_gc_tag_runners" ( "id" bigserial PRIMARY KEY, "rule_id" bigint NOT NULL, @@ -367,12 +467,18 @@ CREATE TABLE IF NOT EXISTS "daemon_gc_tag_runners" ( "duration" bigint, "success_count" bigint, "failed_count" bigint, - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" bigint NOT NULL DEFAULT 0, FOREIGN KEY ("rule_id") REFERENCES "daemon_gc_tag_rules" ("id") ); +CREATE INDEX "daemon_gc_tag_runners_idx_created_at" ON "daemon_gc_tag_runners" ("created_at"); + +CREATE INDEX "daemon_gc_tag_runners_idx_updated_at" ON "daemon_gc_tag_runners" ("updated_at"); + +CREATE INDEX "daemon_gc_tag_runners_idx_deleted_at" ON "daemon_gc_tag_runners" ("deleted_at"); + CREATE TYPE gc_record_status AS ENUM ( 'Success', 'Failed' @@ -384,12 +490,18 @@ CREATE TABLE IF NOT EXISTS "daemon_gc_tag_records" ( "tag" varchar(128) NOT NULL, "status" gc_record_status NOT NULL DEFAULT 'Success', "message" bytea, - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" bigint NOT NULL DEFAULT 0, FOREIGN KEY ("runner_id") REFERENCES "daemon_gc_tag_runners" ("id") ); +CREATE INDEX "daemon_gc_tag_records_idx_created_at" ON "daemon_gc_tag_records" ("created_at"); + +CREATE INDEX "daemon_gc_tag_records_idx_updated_at" ON "daemon_gc_tag_records" ("updated_at"); + +CREATE INDEX "daemon_gc_tag_records_idx_deleted_at" ON "daemon_gc_tag_records" ("deleted_at"); + CREATE TABLE IF NOT EXISTS "daemon_gc_repository_rules" ( "id" bigserial PRIMARY KEY, "namespace_id" bigint, @@ -398,13 +510,19 @@ CREATE TABLE IF NOT EXISTS "daemon_gc_repository_rules" ( "cron_enabled" smallint NOT NULL DEFAULT 0, "cron_rule" varchar(30), "cron_next_trigger" timestamp, - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" bigint NOT NULL DEFAULT 0, FOREIGN KEY ("namespace_id") REFERENCES "namespaces" ("id"), CONSTRAINT "daemon_gc_repository_rules_unique_with_ns" UNIQUE ("namespace_id", "deleted_at") ); +CREATE INDEX "daemon_gc_repository_rules_idx_created_at" ON "daemon_gc_repository_rules" ("created_at"); + +CREATE INDEX "daemon_gc_repository_rules_idx_updated_at" ON "daemon_gc_repository_rules" ("updated_at"); + +CREATE INDEX "daemon_gc_repository_rules_idx_deleted_at" ON "daemon_gc_repository_rules" ("deleted_at"); + CREATE TABLE IF NOT EXISTS "daemon_gc_repository_runners" ( "id" bigserial PRIMARY KEY, "rule_id" bigint NOT NULL, @@ -415,24 +533,36 @@ CREATE TABLE IF NOT EXISTS "daemon_gc_repository_runners" ( "duration" bigint, "success_count" bigint, "failed_count" bigint, - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" integer NOT NULL DEFAULT 0, FOREIGN KEY ("rule_id") REFERENCES "daemon_gc_repository_rules" ("id") ); +CREATE INDEX "daemon_gc_repository_runners_idx_created_at" ON "daemon_gc_repository_runners" ("created_at"); + +CREATE INDEX "daemon_gc_repository_runners_idx_updated_at" ON "daemon_gc_repository_runners" ("updated_at"); + +CREATE INDEX "daemon_gc_repository_runners_idx_deleted_at" ON "daemon_gc_repository_runners" ("deleted_at"); + CREATE TABLE IF NOT EXISTS "daemon_gc_repository_records" ( "id" bigserial PRIMARY KEY, "runner_id" bigint NOT NULL, "repository" varchar(64) NOT NULL, "status" gc_record_status NOT NULL DEFAULT 'Success', "message" bytea, - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" bigint NOT NULL DEFAULT 0, FOREIGN KEY ("runner_id") REFERENCES "daemon_gc_repository_runners" ("id") ); +CREATE INDEX "daemon_gc_repository_records_idx_created_at" ON "daemon_gc_repository_records" ("created_at"); + +CREATE INDEX "daemon_gc_repository_records_idx_updated_at" ON "daemon_gc_repository_records" ("updated_at"); + +CREATE INDEX "daemon_gc_repository_records_idx_deleted_at" ON "daemon_gc_repository_records" ("deleted_at"); + CREATE TABLE IF NOT EXISTS "daemon_gc_artifact_rules" ( "id" bigserial PRIMARY KEY, "namespace_id" bigint, @@ -441,13 +571,19 @@ CREATE TABLE IF NOT EXISTS "daemon_gc_artifact_rules" ( "cron_enabled" smallint NOT NULL DEFAULT 0, "cron_rule" varchar(30), "cron_next_trigger" timestamp, - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" bigint NOT NULL DEFAULT 0, FOREIGN KEY ("namespace_id") REFERENCES "namespaces" ("id"), CONSTRAINT "daemon_gc_artifact_rules_unique_with_ns" UNIQUE ("namespace_id", "deleted_at") ); +CREATE INDEX "daemon_gc_artifact_rules_idx_created_at" ON "daemon_gc_artifact_rules" ("created_at"); + +CREATE INDEX "daemon_gc_artifact_rules_idx_updated_at" ON "daemon_gc_artifact_rules" ("updated_at"); + +CREATE INDEX "daemon_gc_artifact_rules_idx_deleted_at" ON "daemon_gc_artifact_rules" ("deleted_at"); + CREATE TABLE IF NOT EXISTS "daemon_gc_artifact_runners" ( "id" bigserial PRIMARY KEY, "rule_id" bigint NOT NULL, @@ -458,35 +594,53 @@ CREATE TABLE IF NOT EXISTS "daemon_gc_artifact_runners" ( "duration" bigint, "success_count" bigint, "failed_count" bigint, - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" integer NOT NULL DEFAULT 0, FOREIGN KEY ("rule_id") REFERENCES "daemon_gc_artifact_rules" ("id") ); +CREATE INDEX "daemon_gc_artifact_runners_idx_created_at" ON "daemon_gc_artifact_runners" ("created_at"); + +CREATE INDEX "daemon_gc_artifact_runners_idx_updated_at" ON "daemon_gc_artifact_runners" ("updated_at"); + +CREATE INDEX "daemon_gc_artifact_runners_idx_deleted_at" ON "daemon_gc_artifact_runners" ("deleted_at"); + CREATE TABLE IF NOT EXISTS "daemon_gc_artifact_records" ( "id" bigserial PRIMARY KEY, "runner_id" bigint NOT NULL, "digest" varchar(256) NOT NULL, "status" gc_record_status NOT NULL DEFAULT 'Success', "message" bytea, - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" bigint NOT NULL DEFAULT 0, FOREIGN KEY ("runner_id") REFERENCES "daemon_gc_artifact_runners" ("id") ); +CREATE INDEX "daemon_gc_artifact_records_idx_created_at" ON "daemon_gc_artifact_records" ("created_at"); + +CREATE INDEX "daemon_gc_artifact_records_idx_updated_at" ON "daemon_gc_artifact_records" ("updated_at"); + +CREATE INDEX "daemon_gc_artifact_records_idx_deleted_at" ON "daemon_gc_artifact_records" ("deleted_at"); + CREATE TABLE IF NOT EXISTS "daemon_gc_blob_rules" ( "id" bigserial PRIMARY KEY, "retention_day" integer NOT NULL DEFAULT 0, "cron_enabled" smallint NOT NULL DEFAULT 0, "cron_rule" varchar(30), "cron_next_trigger" timestamp, - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" bigint NOT NULL DEFAULT 0 ); +CREATE INDEX "daemon_gc_blob_rules_idx_created_at" ON "daemon_gc_blob_rules" ("created_at"); + +CREATE INDEX "daemon_gc_blob_rules_idx_updated_at" ON "daemon_gc_blob_rules" ("updated_at"); + +CREATE INDEX "daemon_gc_blob_rules_idx_deleted_at" ON "daemon_gc_blob_rules" ("deleted_at"); + CREATE TABLE IF NOT EXISTS "daemon_gc_blob_runners" ( "id" bigserial PRIMARY KEY, "rule_id" bigint NOT NULL, @@ -497,24 +651,36 @@ CREATE TABLE IF NOT EXISTS "daemon_gc_blob_runners" ( "duration" bigint, "success_count" bigint, "failed_count" bigint, - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" integer NOT NULL DEFAULT 0, FOREIGN KEY ("rule_id") REFERENCES "daemon_gc_blob_rules" ("id") ); +CREATE INDEX "daemon_gc_blob_runners_idx_created_at" ON "daemon_gc_blob_runners" ("created_at"); + +CREATE INDEX "daemon_gc_blob_runners_idx_updated_at" ON "daemon_gc_blob_runners" ("updated_at"); + +CREATE INDEX "daemon_gc_blob_runners_idx_deleted_at" ON "daemon_gc_blob_runners" ("deleted_at"); + CREATE TABLE IF NOT EXISTS "daemon_gc_blob_records" ( "id" bigserial PRIMARY KEY, "runner_id" bigint NOT NULL, "digest" varchar(256) NOT NULL, "status" gc_record_status NOT NULL DEFAULT 'Success', "message" bytea, - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" bigint NOT NULL DEFAULT 0, FOREIGN KEY ("runner_id") REFERENCES "daemon_gc_blob_runners" ("id") ); +CREATE INDEX "daemon_gc_blob_records_idx_created_at" ON "daemon_gc_blob_records" ("created_at"); + +CREATE INDEX "daemon_gc_blob_records_idx_updated_at" ON "daemon_gc_blob_records" ("updated_at"); + +CREATE INDEX "daemon_gc_blob_records_idx_deleted_at" ON "daemon_gc_blob_records" ("deleted_at"); + CREATE TABLE "casbin_rules" ( "id" bigserial PRIMARY KEY, "ptype" varchar(100), @@ -538,13 +704,19 @@ CREATE TABLE IF NOT EXISTS "namespace_members" ( "user_id" bigint NOT NULL, "namespace_id" bigint NOT NULL, "role" namespace_member_role NOT NULL DEFAULT 'NamespaceReader', - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" bigint NOT NULL DEFAULT 0, FOREIGN KEY ("user_id") REFERENCES "users" ("id"), CONSTRAINT "namespace_members_unique_with_user_ns_role" UNIQUE ("user_id", "namespace_id", "role", "deleted_at") ); +CREATE INDEX "namespace_members_idx_created_at" ON "namespace_members" ("created_at"); + +CREATE INDEX "namespace_members_idx_updated_at" ON "namespace_members" ("updated_at"); + +CREATE INDEX "namespace_members_idx_deleted_at" ON "namespace_members" ("deleted_at"); + -- ptype type -- v0 sub -- v1 dom @@ -583,11 +755,17 @@ CREATE TABLE IF NOT EXISTS "webhooks" ( "event_tag" smallint NOT NULL DEFAULT 1, "event_pull_push" smallint NOT NULL DEFAULT 1, "event_member" smallint NOT NULL DEFAULT 1, - "created_at" timestamp NOT NULL, - "updated_at" timestamp NOT NULL, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" bigint NOT NULL DEFAULT 0 ); +CREATE INDEX "webhooks_idx_created_at" ON "webhooks" ("created_at"); + +CREATE INDEX "webhooks_idx_updated_at" ON "webhooks" ("updated_at"); + +CREATE INDEX "webhooks_idx_deleted_at" ON "webhooks" ("deleted_at"); + CREATE TABLE IF NOT EXISTS "webhook_logs" ( "id" bigserial PRIMARY KEY, "webhook_id" bigint NOT NULL, @@ -597,12 +775,18 @@ CREATE TABLE IF NOT EXISTS "webhook_logs" ( "req_body" bytea NOT NULL, "resp_header" bytea NOT NULL, "resp_body" bytea, - "created_at" timestamp NOT NULL, - "updated_at" timestamp NOT NULL, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" bigint NOT NULL DEFAULT 0, FOREIGN KEY ("webhook_id") REFERENCES "webhooks" ("id") ); +CREATE INDEX "webhook_logs_idx_created_at" ON "webhook_logs" ("created_at"); + +CREATE INDEX "webhook_logs_idx_updated_at" ON "webhook_logs" ("updated_at"); + +CREATE INDEX "webhook_logs_idx_deleted_at" ON "webhook_logs" ("deleted_at"); + CREATE TYPE builder_source AS ENUM ( 'SelfCodeRepository', 'CodeRepository', @@ -644,14 +828,20 @@ CREATE TABLE IF NOT EXISTS "builders" ( "buildkit_platforms" varchar(256) NOT NULL DEFAULT 'linux/amd64', "buildkit_build_args" varchar(256), -- other fields - "created_at" timestamp NOT NULL, - "updated_at" timestamp NOT NULL, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" bigint NOT NULL DEFAULT 0, FOREIGN KEY ("repository_id") REFERENCES "repositories" ("id"), FOREIGN KEY ("code_repository_id") REFERENCES "code_repositories" ("id"), CONSTRAINT "builders_unique_with_repository" UNIQUE ("repository_id", "deleted_at") ); +CREATE INDEX "builders_idx_created_at" ON "builders" ("created_at"); + +CREATE INDEX "builders_idx_updated_at" ON "builders" ("updated_at"); + +CREATE INDEX "builders_idx_deleted_at" ON "builders" ("deleted_at"); + CREATE TYPE builder_runner_status AS ENUM ( 'Pending', 'Doing', @@ -676,12 +866,18 @@ CREATE TABLE IF NOT EXISTS "builder_runners" ( "ended_at" timestamp, "duration" bigint, -- other fields - "created_at" timestamp NOT NULL, - "updated_at" timestamp NOT NULL, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" bigint NOT NULL DEFAULT 0, FOREIGN KEY ("builder_id") REFERENCES "builders" ("id") ); +CREATE INDEX "builder_runners_idx_created_at" ON "builder_runners" ("created_at"); + +CREATE INDEX "builder_runners_idx_updated_at" ON "builder_runners" ("updated_at"); + +CREATE INDEX "builder_runners_idx_deleted_at" ON "builder_runners" ("deleted_at"); + CREATE TABLE IF NOT EXISTS "work_queues" ( "id" bigserial PRIMARY KEY, "topic" varchar(30) NOT NULL, @@ -689,28 +885,46 @@ CREATE TABLE IF NOT EXISTS "work_queues" ( "times" smallint NOT NULL DEFAULT 0, "version" varchar(36) NOT NULL, "status" daemon_status NOT NULL DEFAULT 'Pending', - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" bigint NOT NULL DEFAULT 0 ); +CREATE INDEX "work_queues_idx_created_at" ON "work_queues" ("created_at"); + +CREATE INDEX "work_queues_idx_updated_at" ON "work_queues" ("updated_at"); + +CREATE INDEX "work_queues_idx_deleted_at" ON "work_queues" ("deleted_at"); + CREATE TABLE IF NOT EXISTS "caches" ( "id" bigserial PRIMARY KEY, "key" varchar(256) NOT NULL UNIQUE, "val" bytea NOT NULL, - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" integer NOT NULL DEFAULT 0 ); +CREATE INDEX "caches_idx_created_at" ON "caches" ("created_at"); + +CREATE INDEX "caches_idx_updated_at" ON "caches" ("updated_at"); + +CREATE INDEX "caches_idx_deleted_at" ON "caches" ("deleted_at"); + CREATE INDEX "idx_created_at" ON "caches" ("created_at"); CREATE TABLE IF NOT EXISTS "settings" ( "id" bigserial PRIMARY KEY, "key" varchar(256) NOT NULL UNIQUE, "val" bytea, - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), + "updated_at" bigint NOT NULL DEFAULT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000)::bigint), "deleted_at" bigint NOT NULL DEFAULT 0 ); +CREATE INDEX "settings_idx_created_at" ON "settings" ("created_at"); + +CREATE INDEX "settings_idx_updated_at" ON "settings" ("updated_at"); + +CREATE INDEX "settings_idx_deleted_at" ON "settings" ("deleted_at"); + diff --git a/pkg/dal/migrations/sqlite3/0001_initialize.up.sql b/pkg/dal/migrations/sqlite3/0001_initialize.up.sql index bd935b2c..24b3867f 100644 --- a/pkg/dal/migrations/sqlite3/0001_initialize.up.sql +++ b/pkg/dal/migrations/sqlite3/0001_initialize.up.sql @@ -8,14 +8,18 @@ CREATE TABLE IF NOT EXISTS `users` ( `namespace_count` bigint NOT NULL DEFAULT 0, `status` text CHECK (`status` IN ('Active', 'Inactive')) NOT NULL DEFAULT 'Active', `role` text CHECK (`role` IN ('Root', 'Admin', 'User')) NOT NULL DEFAULT 'User', - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, CONSTRAINT `users_unique_with_username` UNIQUE (`username`, `deleted_at`) ); CREATE INDEX `users_idx_created_at` ON `users` (`created_at`); +CREATE INDEX `users_idx_updated_at` ON `users` (`updated_at`); + +CREATE INDEX `users_idx_deleted_at` ON `users` (`deleted_at`); + CREATE INDEX `users_idx_status` ON `users` (`status`); CREATE INDEX `users_idx_role` ON `users` (`role`); @@ -32,13 +36,19 @@ CREATE TABLE IF NOT EXISTS `user_3rdparty` ( `cr_last_update_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `cr_last_update_status` text CHECK (`cr_last_update_status` IN ('Success', 'Failed', 'Doing')) NOT NULL DEFAULT 'Doing', `cr_last_update_message` varchar(256), - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, FOREIGN KEY (`user_id`) REFERENCES `users` (`id`), CONSTRAINT `user_3rdparty_unique_with_account_id` UNIQUE (`provider`, `account_id`, `deleted_at`) ); +CREATE INDEX `user_3rdparty_idx_created_at` ON `user_3rdparty` (`created_at`); + +CREATE INDEX `user_3rdparty_idx_updated_at` ON `user_3rdparty` (`updated_at`); + +CREATE INDEX `user_3rdparty_idx_deleted_at` ON `user_3rdparty` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `code_repository_clone_credentials` ( `id` integer PRIMARY KEY AUTOINCREMENT, `user_3rdparty_id` bigint NOT NULL, @@ -47,25 +57,37 @@ CREATE TABLE IF NOT EXISTS `code_repository_clone_credentials` ( `username` varchar(256), `password` varchar(256), `token` varchar(256), - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, FOREIGN KEY (`user_3rdparty_id`) REFERENCES `user_3rdparty` (`id`) ); +CREATE INDEX `code_repository_clone_credentials_idx_created_at` ON `code_repository_clone_credentials` (`created_at`); + +CREATE INDEX `code_repository_clone_credentials_idx_updated_at` ON `code_repository_clone_credentials` (`updated_at`); + +CREATE INDEX `code_repository_clone_credentials_idx_deleted_at` ON `code_repository_clone_credentials` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `code_repository_owners` ( `id` integer PRIMARY KEY AUTOINCREMENT, `user_3rdparty_id` bigint NOT NULL, `is_org` integer NOT NULL DEFAULT 0, `owner_id` varchar(256) NOT NULL, `owner` varchar(256) NOT NULL, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, FOREIGN KEY (`user_3rdparty_id`) REFERENCES `user_3rdparty` (`id`), CONSTRAINT `code_repository_owners_unique_with_name` UNIQUE (`user_3rdparty_id`, `owner_id`, `deleted_at`) ); +CREATE INDEX `code_repository_owners_idx_created_at` ON `code_repository_owners` (`created_at`); + +CREATE INDEX `code_repository_owners_idx_updated_at` ON `code_repository_owners` (`updated_at`); + +CREATE INDEX `code_repository_owners_idx_deleted_at` ON `code_repository_owners` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `code_repositories` ( `id` integer PRIMARY KEY AUTOINCREMENT, `user_3rdparty_id` integer NOT NULL, @@ -77,35 +99,53 @@ CREATE TABLE IF NOT EXISTS `code_repositories` ( `ssh_url` varchar(256) NOT NULL, `clone_url` varchar(256) NOT NULL, `oci_repo_count` integer NOT NULL DEFAULT 0, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` integer NOT NULL DEFAULT 0, FOREIGN KEY (`user_3rdparty_id`) REFERENCES `user_3rdparty` (`id`), CONSTRAINT `code_repositories_unique_with_name` UNIQUE (`user_3rdparty_id`, `owner_id`, `repository_id`, `deleted_at`) ); +CREATE INDEX `code_repositories_idx_created_at` ON `code_repositories` (`created_at`); + +CREATE INDEX `code_repositories_idx_updated_at` ON `code_repositories` (`updated_at`); + +CREATE INDEX `code_repositories_idx_deleted_at` ON `code_repositories` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `code_repository_branches` ( `id` integer PRIMARY KEY AUTOINCREMENT, `code_repository_id` integer NOT NULL, `name` varchar(256) NOT NULL, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` integer NOT NULL DEFAULT 0, FOREIGN KEY (`code_repository_id`) REFERENCES `code_repositories` (`id`), CONSTRAINT `code_repository_branches_unique_with_name` UNIQUE (`code_repository_id`, `name`, `deleted_at`) ); +CREATE INDEX `code_repository_branches_idx_created_at` ON `code_repository_branches` (`created_at`); + +CREATE INDEX `code_repository_branches_idx_updated_at` ON `code_repository_branches` (`updated_at`); + +CREATE INDEX `code_repository_branches_idx_deleted_at` ON `code_repository_branches` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `user_recover_codes` ( `id` integer PRIMARY KEY AUTOINCREMENT, `user_id` integer NOT NULL, `code` varchar(256) NOT NULL, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` integer NOT NULL DEFAULT 0, FOREIGN KEY (`user_id`) REFERENCES `users` (`id`), CONSTRAINT `user_recover_codes_unique_with_use_id` UNIQUE (`user_id`, `deleted_at`) ); +CREATE INDEX `user_recover_codes_idx_created_at` ON `user_recover_codes` (`created_at`); + +CREATE INDEX `user_recover_codes_idx_updated_at` ON `user_recover_codes` (`updated_at`); + +CREATE INDEX `user_recover_codes_idx_deleted_at` ON `user_recover_codes` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `namespaces` ( `id` integer PRIMARY KEY AUTOINCREMENT, `name` varchar(64) NOT NULL, @@ -117,12 +157,18 @@ CREATE TABLE IF NOT EXISTS `namespaces` ( `repository_count` integer NOT NULL DEFAULT 0, `tag_limit` integer NOT NULL DEFAULT 0, `tag_count` integer NOT NULL DEFAULT 0, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `deleted_at` bigint NOT NULL DEFAULT 0, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `deleted_at` integer NOT NULL DEFAULT 0, CONSTRAINT `namespaces_unique_with_name` UNIQUE (`name`, `deleted_at`) ); +CREATE INDEX `namespaces_idx_created_at` ON `namespaces` (`created_at`); + +CREATE INDEX `namespaces_idx_updated_at` ON `namespaces` (`updated_at`); + +CREATE INDEX `namespaces_idx_deleted_at` ON `namespaces` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `audits` ( `id` integer PRIMARY KEY AUTOINCREMENT, `user_id` bigint NOT NULL, @@ -132,13 +178,19 @@ CREATE TABLE IF NOT EXISTS `audits` ( `resource` varchar(256) NOT NULL, `before_raw` BLOB, `req_raw` BLOB, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, FOREIGN KEY (`user_id`) REFERENCES `users` (`id`), FOREIGN KEY (`namespace_id`) REFERENCES `namespaces` (`id`) ); +CREATE INDEX `audits_idx_created_at` ON `audits` (`created_at`); + +CREATE INDEX `audits_idx_updated_at` ON `audits` (`updated_at`); + +CREATE INDEX `audits_idx_deleted_at` ON `audits` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `repositories` ( `id` integer PRIMARY KEY AUTOINCREMENT, `name` varchar(64) NOT NULL, @@ -150,13 +202,19 @@ CREATE TABLE IF NOT EXISTS `repositories` ( `tag_limit` integer NOT NULL DEFAULT 0, `tag_count` integer NOT NULL DEFAULT 0, `namespace_id` integer NOT NULL, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` integer NOT NULL DEFAULT 0, FOREIGN KEY (`namespace_id`) REFERENCES `namespaces` (`id`), CONSTRAINT `repositories_unique_with_namespace` UNIQUE (`namespace_id`, `name`, `deleted_at`) ); +CREATE INDEX `repositories_idx_created_at` ON `repositories` (`created_at`); + +CREATE INDEX `repositories_idx_updated_at` ON `repositories` (`updated_at`); + +CREATE INDEX `repositories_idx_deleted_at` ON `repositories` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `artifacts` ( `id` integer PRIMARY KEY AUTOINCREMENT, `repository_id` integer NOT NULL, @@ -172,14 +230,20 @@ CREATE TABLE IF NOT EXISTS `artifacts` ( `last_pull` timestamp, `referrer_id` integer, `pull_times` bigint NOT NULL DEFAULT 0, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, FOREIGN KEY (`repository_id`) REFERENCES `repositories` (`id`), FOREIGN KEY (`referrer_id`) REFERENCES `artifacts` (`id`), CONSTRAINT `artifacts_unique_with_repo` UNIQUE (`repository_id`, `digest`, `deleted_at`) ); +CREATE INDEX `artifacts_idx_created_at` ON `artifacts` (`created_at`); + +CREATE INDEX `artifacts_idx_updated_at` ON `artifacts` (`updated_at`); + +CREATE INDEX `artifacts_idx_deleted_at` ON `artifacts` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `artifact_sboms` ( `id` integer PRIMARY KEY AUTOINCREMENT, `artifact_id` integer NOT NULL, @@ -189,13 +253,19 @@ CREATE TABLE IF NOT EXISTS `artifact_sboms` ( `stdout` BLOB, `stderr` BLOB, `message` varchar(256), - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, FOREIGN KEY (`artifact_id`) REFERENCES `artifacts` (`id`), CONSTRAINT `artifact_sbom_unique_with_artifact` UNIQUE (`artifact_id`, `deleted_at`) ); +CREATE INDEX `artifact_sboms_idx_created_at` ON `artifact_sboms` (`created_at`); + +CREATE INDEX `artifact_sboms_idx_updated_at` ON `artifact_sboms` (`updated_at`); + +CREATE INDEX `artifact_sboms_idx_deleted_at` ON `artifact_sboms` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `artifact_vulnerabilities` ( `id` integer PRIMARY KEY AUTOINCREMENT, `artifact_id` integer NOT NULL, @@ -206,13 +276,19 @@ CREATE TABLE IF NOT EXISTS `artifact_vulnerabilities` ( `stdout` BLOB, `stderr` BLOB, `message` varchar(256), - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, FOREIGN KEY (`artifact_id`) REFERENCES `artifacts` (`id`), CONSTRAINT `artifact_vulnerability_unique_with_artifact` UNIQUE (`artifact_id`, `deleted_at`) ); +CREATE INDEX `artifact_vulnerabilities_idx_created_at` ON `artifact_vulnerabilities` (`created_at`); + +CREATE INDEX `artifact_vulnerabilities_idx_updated_at` ON `artifact_vulnerabilities` (`updated_at`); + +CREATE INDEX `artifact_vulnerabilities_idx_deleted_at` ON `artifact_vulnerabilities` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `tags` ( `id` integer PRIMARY KEY AUTOINCREMENT, `repository_id` integer NOT NULL, @@ -221,14 +297,20 @@ CREATE TABLE IF NOT EXISTS `tags` ( `pushed_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `last_pull` timestamp, `pull_times` integer NOT NULL DEFAULT 0, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, FOREIGN KEY (`repository_id`) REFERENCES `repositories` (`id`), FOREIGN KEY (`artifact_id`) REFERENCES `artifacts` (`id`), CONSTRAINT `tags_unique_with_repo` UNIQUE (`repository_id`, `name`, `deleted_at`) ); +CREATE INDEX `tags_idx_created_at` ON `tags` (`created_at`); + +CREATE INDEX `tags_idx_updated_at` ON `tags` (`updated_at`); + +CREATE INDEX `tags_idx_deleted_at` ON `tags` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `blobs` ( `id` integer PRIMARY KEY AUTOINCREMENT, `digest` varchar(256) NOT NULL UNIQUE, @@ -237,12 +319,18 @@ CREATE TABLE IF NOT EXISTS `blobs` ( `pushed_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `last_pull` timestamp, `pull_times` integer NOT NULL DEFAULT 0, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, CONSTRAINT `blobs_unique_with_digest` UNIQUE (`digest`, `deleted_at`) ); +CREATE INDEX `blobs_idx_created_at` ON `blobs` (`created_at`); + +CREATE INDEX `blobs_idx_updated_at` ON `blobs` (`updated_at`); + +CREATE INDEX `blobs_idx_deleted_at` ON `blobs` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `blob_uploads` ( `id` integer PRIMARY KEY AUTOINCREMENT, `part_number` int NOT NULL, @@ -251,12 +339,18 @@ CREATE TABLE IF NOT EXISTS `blob_uploads` ( `repository` varchar(256) NOT NULL, `file_id` varchar(256) NOT NULL, `size` integer NOT NULL DEFAULT 0, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` bigint NOT NULL DEFAULT 0, CONSTRAINT `blob_uploads_unique_with_upload_id_etag` UNIQUE (`upload_id`, `etag`, `deleted_at`) ); +CREATE INDEX `blob_uploads_idx_created_at` ON `blob_uploads` (`created_at`); + +CREATE INDEX `blob_uploads_idx_updated_at` ON `blob_uploads` (`updated_at`); + +CREATE INDEX `blob_uploads_idx_deleted_at` ON `blob_uploads` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `artifact_artifacts` ( `artifact_id` integer NOT NULL, `artifact_index_id` integer NOT NULL, @@ -283,13 +377,19 @@ CREATE TABLE IF NOT EXISTS `daemon_gc_tag_rules` ( `retention_rule_type` text CHECK (`retention_rule_type` IN ('Day', 'Quantity')) NOT NULL DEFAULT 'Quantity', `retention_rule_amount` integer NOT NULL DEFAULT 1, `retention_pattern` varchar(64), - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` integer NOT NULL DEFAULT 0, FOREIGN KEY (`namespace_id`) REFERENCES `namespaces` (`id`), CONSTRAINT `daemon_gc_tag_rules_unique_with_ns` UNIQUE (`namespace_id`, `deleted_at`) ); +CREATE INDEX `daemon_gc_tag_rules_idx_created_at` ON `daemon_gc_tag_rules` (`created_at`); + +CREATE INDEX `daemon_gc_tag_rules_idx_updated_at` ON `daemon_gc_tag_rules` (`updated_at`); + +CREATE INDEX `daemon_gc_tag_rules_idx_deleted_at` ON `daemon_gc_tag_rules` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `daemon_gc_tag_runners` ( `id` integer PRIMARY KEY AUTOINCREMENT, `rule_id` integer NOT NULL, @@ -300,24 +400,36 @@ CREATE TABLE IF NOT EXISTS `daemon_gc_tag_runners` ( `duration` integer, `success_count` integer, `failed_count` integer, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` integer NOT NULL DEFAULT 0, FOREIGN KEY (`rule_id`) REFERENCES `daemon_gc_tag_rules` (`id`) ); +CREATE INDEX `daemon_gc_tag_runners_idx_created_at` ON `daemon_gc_tag_runners` (`created_at`); + +CREATE INDEX `daemon_gc_tag_runners_idx_updated_at` ON `daemon_gc_tag_runners` (`updated_at`); + +CREATE INDEX `daemon_gc_tag_runners_idx_deleted_at` ON `daemon_gc_tag_runners` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `daemon_gc_tag_records` ( `id` integer PRIMARY KEY AUTOINCREMENT, `runner_id` integer NOT NULL, `tag` varchar(128) NOT NULL, `status` text CHECK (`status` IN ('Success', 'Failed')) NOT NULL DEFAULT 'Success', `message` BLOB, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` integer NOT NULL DEFAULT 0, FOREIGN KEY (`runner_id`) REFERENCES `daemon_gc_tag_runners` (`id`) ); +CREATE INDEX `daemon_gc_tag_records_idx_created_at` ON `daemon_gc_tag_records` (`created_at`); + +CREATE INDEX `daemon_gc_tag_records_idx_updated_at` ON `daemon_gc_tag_records` (`updated_at`); + +CREATE INDEX `daemon_gc_tag_records_idx_deleted_at` ON `daemon_gc_tag_records` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `daemon_gc_repository_rules` ( `id` integer PRIMARY KEY AUTOINCREMENT, `namespace_id` integer, @@ -326,13 +438,19 @@ CREATE TABLE IF NOT EXISTS `daemon_gc_repository_rules` ( `cron_enabled` integer NOT NULL DEFAULT 0, `cron_rule` varchar(30), `cron_next_trigger` timestamp, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` integer NOT NULL DEFAULT 0, FOREIGN KEY (`namespace_id`) REFERENCES `namespaces` (`id`), CONSTRAINT `daemon_gc_repository_rules_unique_with_ns` UNIQUE (`namespace_id`, `deleted_at`) ); +CREATE INDEX `daemon_gc_repository_rules_idx_created_at` ON `daemon_gc_repository_rules` (`created_at`); + +CREATE INDEX `daemon_gc_repository_rules_idx_updated_at` ON `daemon_gc_repository_rules` (`updated_at`); + +CREATE INDEX `daemon_gc_repository_rules_idx_deleted_at` ON `daemon_gc_repository_rules` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `daemon_gc_repository_runners` ( `id` integer PRIMARY KEY AUTOINCREMENT, `rule_id` bigint NOT NULL, @@ -343,24 +461,36 @@ CREATE TABLE IF NOT EXISTS `daemon_gc_repository_runners` ( `duration` integer, `success_count` integer, `failed_count` integer, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` integer NOT NULL DEFAULT 0, FOREIGN KEY (`rule_id`) REFERENCES `daemon_gc_repository_rules` (`id`) ); +CREATE INDEX `daemon_gc_repository_runners_idx_created_at` ON `daemon_gc_repository_runners` (`created_at`); + +CREATE INDEX `daemon_gc_repository_runners_idx_updated_at` ON `daemon_gc_repository_runners` (`updated_at`); + +CREATE INDEX `daemon_gc_repository_runners_idx_deleted_at` ON `daemon_gc_repository_runners` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `daemon_gc_repository_records` ( `id` integer PRIMARY KEY AUTOINCREMENT, `runner_id` integer NOT NULL, `repository` varchar(64) NOT NULL, `status` text CHECK (`status` IN ('Success', 'Failed')) NOT NULL DEFAULT 'Success', `message` BLOB, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` integer NOT NULL DEFAULT 0, FOREIGN KEY (`runner_id`) REFERENCES `daemon_gc_repository_runners` (`id`) ); +CREATE INDEX `daemon_gc_repository_records_idx_created_at` ON `daemon_gc_repository_records` (`created_at`); + +CREATE INDEX `daemon_gc_repository_records_idx_updated_at` ON `daemon_gc_repository_records` (`updated_at`); + +CREATE INDEX `daemon_gc_repository_records_idx_deleted_at` ON `daemon_gc_repository_records` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `daemon_gc_artifact_rules` ( `id` integer PRIMARY KEY AUTOINCREMENT, `namespace_id` integer, @@ -369,13 +499,19 @@ CREATE TABLE IF NOT EXISTS `daemon_gc_artifact_rules` ( `cron_enabled` integer NOT NULL DEFAULT 0, `cron_rule` varchar(30), `cron_next_trigger` timestamp, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` integer NOT NULL DEFAULT 0, FOREIGN KEY (`namespace_id`) REFERENCES `namespaces` (`id`), CONSTRAINT `daemon_gc_artifact_rules_unique_with_ns` UNIQUE (`namespace_id`, `deleted_at`) ); +CREATE INDEX `daemon_gc_artifact_rules_idx_created_at` ON `daemon_gc_artifact_rules` (`created_at`); + +CREATE INDEX `daemon_gc_artifact_rules_idx_updated_at` ON `daemon_gc_artifact_rules` (`updated_at`); + +CREATE INDEX `daemon_gc_artifact_rules_idx_deleted_at` ON `daemon_gc_artifact_rules` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `daemon_gc_artifact_runners` ( `id` integer PRIMARY KEY AUTOINCREMENT, `status` text CHECK (`status` IN ('Success', 'Failed', 'Pending', 'Doing')) NOT NULL DEFAULT 'Pending', @@ -386,24 +522,36 @@ CREATE TABLE IF NOT EXISTS `daemon_gc_artifact_runners` ( `duration` integer, `success_count` integer, `failed_count` integer, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` integer NOT NULL DEFAULT 0, FOREIGN KEY (`rule_id`) REFERENCES `daemon_gc_artifact_rules` (`id`) ); +CREATE INDEX `daemon_gc_artifact_runners_idx_created_at` ON `daemon_gc_artifact_runners` (`created_at`); + +CREATE INDEX `daemon_gc_artifact_runners_idx_updated_at` ON `daemon_gc_artifact_runners` (`updated_at`); + +CREATE INDEX `daemon_gc_artifact_runners_idx_deleted_at` ON `daemon_gc_artifact_runners` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `daemon_gc_artifact_records` ( `id` integer PRIMARY KEY AUTOINCREMENT, `runner_id` integer NOT NULL, `digest` varchar(256) NOT NULL, `status` text CHECK (`status` IN ('Success', 'Failed')) NOT NULL DEFAULT 'Success', `message` BLOB, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` integer NOT NULL DEFAULT 0, FOREIGN KEY (`runner_id`) REFERENCES `daemon_gc_artifact_runners` (`id`) ); +CREATE INDEX `daemon_gc_artifact_records_idx_created_at` ON `daemon_gc_artifact_records` (`created_at`); + +CREATE INDEX `daemon_gc_artifact_records_idx_updated_at` ON `daemon_gc_artifact_records` (`updated_at`); + +CREATE INDEX `daemon_gc_artifact_records_idx_deleted_at` ON `daemon_gc_artifact_records` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `daemon_gc_blob_rules` ( `id` integer PRIMARY KEY AUTOINCREMENT, `is_running` integer NOT NULL DEFAULT 0, @@ -411,11 +559,17 @@ CREATE TABLE IF NOT EXISTS `daemon_gc_blob_rules` ( `cron_enabled` integer NOT NULL DEFAULT 0, `cron_rule` varchar(30), `cron_next_trigger` timestamp, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` integer NOT NULL DEFAULT 0 ); +CREATE INDEX `daemon_gc_blob_rules_idx_created_at` ON `daemon_gc_blob_rules` (`created_at`); + +CREATE INDEX `daemon_gc_blob_rules_idx_updated_at` ON `daemon_gc_blob_rules` (`updated_at`); + +CREATE INDEX `daemon_gc_blob_rules_idx_deleted_at` ON `daemon_gc_blob_rules` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `daemon_gc_blob_runners` ( `id` integer PRIMARY KEY AUTOINCREMENT, `rule_id` integer NOT NULL, @@ -426,24 +580,36 @@ CREATE TABLE IF NOT EXISTS `daemon_gc_blob_runners` ( `duration` integer, `success_count` integer, `failed_count` integer, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` integer NOT NULL DEFAULT 0, FOREIGN KEY (`rule_id`) REFERENCES `daemon_gc_blob_rules` (`id`) ); +CREATE INDEX `daemon_gc_blob_runners_idx_created_at` ON `daemon_gc_blob_runners` (`created_at`); + +CREATE INDEX `daemon_gc_blob_runners_idx_updated_at` ON `daemon_gc_blob_runners` (`updated_at`); + +CREATE INDEX `daemon_gc_blob_runners_idx_deleted_at` ON `daemon_gc_blob_runners` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `daemon_gc_blob_records` ( `id` integer PRIMARY KEY AUTOINCREMENT, `runner_id` integer NOT NULL, `digest` varchar(256) NOT NULL, `status` text CHECK (`status` IN ('Success', 'Failed')) NOT NULL DEFAULT 'Success', `message` BLOB, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` integer NOT NULL DEFAULT 0, FOREIGN KEY (`runner_id`) REFERENCES `daemon_gc_blob_runners` (`id`) ); +CREATE INDEX `daemon_gc_blob_records_idx_created_at` ON `daemon_gc_blob_records` (`created_at`); + +CREATE INDEX `daemon_gc_blob_records_idx_updated_at` ON `daemon_gc_blob_records` (`updated_at`); + +CREATE INDEX `daemon_gc_blob_records_idx_deleted_at` ON `daemon_gc_blob_records` (`deleted_at`); + CREATE TABLE `casbin_rules` ( `id` integer PRIMARY KEY AUTOINCREMENT, `ptype` text, @@ -461,14 +627,20 @@ CREATE TABLE IF NOT EXISTS `namespace_members` ( `user_id` integer NOT NULL, `namespace_id` integer NOT NULL, `role` text CHECK (`role` IN ('NamespaceReader', 'NamespaceManager', 'NamespaceAdmin')) NOT NULL DEFAULT 'NamespaceReader', - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` integer NOT NULL DEFAULT 0, FOREIGN KEY (`user_id`) REFERENCES `users` (`id`), FOREIGN KEY (`namespace_id`) REFERENCES `namespaces` (`id`), CONSTRAINT `namespace_members_unique_with_user_ns_role` UNIQUE (`user_id`, `namespace_id`, `role`, `deleted_at`) ); +CREATE INDEX `namespace_members_idx_created_at` ON `namespace_members` (`created_at`); + +CREATE INDEX `namespace_members_idx_updated_at` ON `namespace_members` (`updated_at`); + +CREATE INDEX `namespace_members_idx_deleted_at` ON `namespace_members` (`deleted_at`); + -- ptype type -- v0 sub -- v1 dom @@ -507,11 +679,17 @@ CREATE TABLE IF NOT EXISTS `webhooks` ( `event_tag` integer NOT NULL DEFAULT 1, `event_pull_push` integer NOT NULL DEFAULT 1, `event_member` integer NOT NULL DEFAULT 1, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` integer NOT NULL DEFAULT 0 ); +CREATE INDEX `webhooks_idx_created_at` ON `webhooks` (`created_at`); + +CREATE INDEX `webhooks_idx_updated_at` ON `webhooks` (`updated_at`); + +CREATE INDEX `webhooks_idx_deleted_at` ON `webhooks` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `webhook_logs` ( `id` integer PRIMARY KEY AUTOINCREMENT, `webhook_id` integer NOT NULL, @@ -521,12 +699,18 @@ CREATE TABLE IF NOT EXISTS `webhook_logs` ( `req_body` BLOB NOT NULL, `resp_header` BLOB NOT NULL, `resp_body` BLOB, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` integer NOT NULL DEFAULT 0, FOREIGN KEY (`webhook_id`) REFERENCES `webhooks` (`id`) ); +CREATE INDEX `webhook_logs_idx_created_at` ON `webhook_logs` (`created_at`); + +CREATE INDEX `webhook_logs_idx_updated_at` ON `webhook_logs` (`updated_at`); + +CREATE INDEX `webhook_logs_idx_deleted_at` ON `webhook_logs` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `builders` ( `id` integer PRIMARY KEY AUTOINCREMENT, `repository_id` integer NOT NULL, @@ -562,13 +746,19 @@ CREATE TABLE IF NOT EXISTS `builders` ( `buildkit_platforms` varchar(256) NOT NULL DEFAULT 'linux/amd64', `buildkit_build_args` varchar(256), -- other fields - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` integer NOT NULL DEFAULT 0, FOREIGN KEY (`repository_id`) REFERENCES `repositories` (`id`), CONSTRAINT `builders_unique_with_repository` UNIQUE (`repository_id`, `deleted_at`) ); +CREATE INDEX `builders_idx_created_at` ON `builders` (`created_at`); + +CREATE INDEX `builders_idx_updated_at` ON `builders` (`updated_at`); + +CREATE INDEX `builders_idx_deleted_at` ON `builders` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `builder_runners` ( `id` integer PRIMARY KEY AUTOINCREMENT, `builder_id` integer NOT NULL, @@ -583,12 +773,18 @@ CREATE TABLE IF NOT EXISTS `builder_runners` ( `ended_at` timestamp, `duration` integer, -- other fields - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` integer NOT NULL DEFAULT 0, FOREIGN KEY (`builder_id`) REFERENCES `builders` (`id`) ); +CREATE INDEX `builder_runners_idx_created_at` ON `builder_runners` (`created_at`); + +CREATE INDEX `builder_runners_idx_updated_at` ON `builder_runners` (`updated_at`); + +CREATE INDEX `builder_runners_idx_deleted_at` ON `builder_runners` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `work_queues` ( `id` integer PRIMARY KEY AUTOINCREMENT, `topic` varchar(30) NOT NULL, @@ -596,28 +792,46 @@ CREATE TABLE IF NOT EXISTS `work_queues` ( `times` integer NOT NULL DEFAULT 0, `version` varchar(36) NOT NULL, `status` text CHECK (`status` IN ('Success', 'Failed', 'Pending', 'Doing')) NOT NULL DEFAULT 'Pending', - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` integer NOT NULL DEFAULT 0 ); +CREATE INDEX `work_queues_idx_created_at` ON `work_queues` (`created_at`); + +CREATE INDEX `work_queues_idx_updated_at` ON `work_queues` (`updated_at`); + +CREATE INDEX `work_queues_idx_deleted_at` ON `work_queues` (`deleted_at`); + CREATE TABLE IF NOT EXISTS `caches` ( `id` integer PRIMARY KEY AUTOINCREMENT, `key` varchar(256) NOT NULL UNIQUE, `val` BLOB NOT NULL, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` integer NOT NULL DEFAULT 0 ); +CREATE INDEX `caches_idx_created_at` ON `caches` (`created_at`); + +CREATE INDEX `caches_idx_updated_at` ON `caches` (`updated_at`); + +CREATE INDEX `caches_idx_deleted_at` ON `caches` (`deleted_at`); + CREATE INDEX `idx_created_at` ON `caches` (`created_at`); CREATE TABLE IF NOT EXISTS `settings` ( `id` integer PRIMARY KEY AUTOINCREMENT, `key` varchar(256) NOT NULL UNIQUE, `val` BLOB, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` integer NOT NULL DEFAULT (unixepoch () * 1000), + `updated_at` integer NOT NULL DEFAULT (unixepoch () * 1000), `deleted_at` integer NOT NULL DEFAULT 0 ); +CREATE INDEX `settings_idx_created_at` ON `settings` (`created_at`); + +CREATE INDEX `settings_idx_updated_at` ON `settings` (`updated_at`); + +CREATE INDEX `settings_idx_deleted_at` ON `settings` (`deleted_at`); + diff --git a/pkg/dal/models/artifact.go b/pkg/dal/models/artifact.go index b50e61d0..d9d0f824 100644 --- a/pkg/dal/models/artifact.go +++ b/pkg/dal/models/artifact.go @@ -28,8 +28,8 @@ import ( // Artifact represents an artifact type Artifact struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` @@ -160,8 +160,8 @@ WHERE // ArtifactSbom represents an artifact sbom type ArtifactSbom struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` @@ -178,8 +178,8 @@ type ArtifactSbom struct { // ArtifactVulnerability represents an artifact vulnerability type ArtifactVulnerability struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` diff --git a/pkg/dal/models/audit.go b/pkg/dal/models/audit.go index 9f9e59e0..ab6c000b 100644 --- a/pkg/dal/models/audit.go +++ b/pkg/dal/models/audit.go @@ -15,8 +15,6 @@ package models import ( - "time" - "gorm.io/plugin/soft_delete" "github.com/go-sigma/sigma/pkg/types/enums" @@ -24,8 +22,8 @@ import ( // Audit represents a audit type Audit struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` diff --git a/pkg/dal/models/blob.go b/pkg/dal/models/blob.go index f0304c72..923957af 100644 --- a/pkg/dal/models/blob.go +++ b/pkg/dal/models/blob.go @@ -24,8 +24,8 @@ import ( // Blob represents a blob type Blob struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` diff --git a/pkg/dal/models/blob_upload.go b/pkg/dal/models/blob_upload.go index 2ddc4e69..fef8c04f 100644 --- a/pkg/dal/models/blob_upload.go +++ b/pkg/dal/models/blob_upload.go @@ -15,14 +15,12 @@ package models import ( - "time" - "gorm.io/plugin/soft_delete" ) type BlobUpload struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` diff --git a/pkg/dal/models/builder.go b/pkg/dal/models/builder.go index 4fec62e4..70604556 100644 --- a/pkg/dal/models/builder.go +++ b/pkg/dal/models/builder.go @@ -26,8 +26,8 @@ import ( // Builder represents a builder type Builder struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` @@ -75,8 +75,8 @@ type Builder struct { // BuilderRunner represents a builder runner type BuilderRunner struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` diff --git a/pkg/dal/models/cache.go b/pkg/dal/models/cache.go index 3354359b..caaa93b6 100644 --- a/pkg/dal/models/cache.go +++ b/pkg/dal/models/cache.go @@ -15,15 +15,13 @@ package models import ( - "time" - "gorm.io/plugin/soft_delete" ) // Cache cache type Cache struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` diff --git a/pkg/dal/models/code_repository.go b/pkg/dal/models/code_repository.go index 61cdb50d..94c2f1ff 100644 --- a/pkg/dal/models/code_repository.go +++ b/pkg/dal/models/code_repository.go @@ -15,8 +15,6 @@ package models import ( - "time" - "gorm.io/plugin/soft_delete" "github.com/go-sigma/sigma/pkg/types/enums" @@ -24,8 +22,8 @@ import ( // CodeRepository ... type CodeRepository struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` @@ -47,8 +45,8 @@ type CodeRepository struct { // CodeRepositoryBranch ... type CodeRepositoryBranch struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` @@ -58,8 +56,8 @@ type CodeRepositoryBranch struct { // CodeRepositoryOwner ... type CodeRepositoryOwner struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` @@ -73,8 +71,8 @@ type CodeRepositoryOwner struct { // CodeRepositoryCloneCredential ... type CodeRepositoryCloneCredential struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` diff --git a/pkg/dal/models/daemon.go b/pkg/dal/models/daemon.go index 659d5869..aaa6580b 100644 --- a/pkg/dal/models/daemon.go +++ b/pkg/dal/models/daemon.go @@ -22,25 +22,10 @@ import ( "github.com/go-sigma/sigma/pkg/types/enums" ) -// DaemonLog represents an artifact -// type DaemonLog struct { -// CreatedAt time.Time -// UpdatedAt time.Time -// DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` -// ID int64 `gorm:"primaryKey"` - -// NamespaceID *int64 -// Type enums.Daemon -// Action enums.AuditAction -// Resource string -// Status enums.TaskCommonStatus -// Message []byte -// } - // DaemonGcTagRule ... type DaemonGcTagRule struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` @@ -58,8 +43,8 @@ type DaemonGcTagRule struct { // DaemonGcTagRunner ... type DaemonGcTagRunner struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` @@ -78,8 +63,8 @@ type DaemonGcTagRunner struct { // DaemonGcTagRecords ... type DaemonGcTagRecord struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` @@ -93,8 +78,8 @@ type DaemonGcTagRecord struct { // DaemonGcRepositoryRule ... type DaemonGcRepositoryRule struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` @@ -110,8 +95,8 @@ type DaemonGcRepositoryRule struct { // DaemonGcRepositoryRunner ... type DaemonGcRepositoryRunner struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` @@ -130,8 +115,8 @@ type DaemonGcRepositoryRunner struct { // DaemonGcRepositoryRecord ... type DaemonGcRepositoryRecord struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` @@ -145,8 +130,8 @@ type DaemonGcRepositoryRecord struct { // DaemonGcArtifactRule ... type DaemonGcArtifactRule struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` @@ -161,8 +146,8 @@ type DaemonGcArtifactRule struct { } type DaemonGcArtifactRunner struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` @@ -181,8 +166,8 @@ type DaemonGcArtifactRunner struct { // DaemonGcArtifactRecord ... type DaemonGcArtifactRecord struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` @@ -196,8 +181,8 @@ type DaemonGcArtifactRecord struct { // DaemonGcBlobRule ... type DaemonGcBlobRule struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` @@ -210,8 +195,8 @@ type DaemonGcBlobRule struct { // DaemonGcBlobRunner ... type DaemonGcBlobRunner struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` @@ -229,8 +214,8 @@ type DaemonGcBlobRunner struct { } type DaemonGcBlobRecord struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` diff --git a/pkg/dal/models/locker.go b/pkg/dal/models/locker.go index c6e431ad..45c96fd2 100644 --- a/pkg/dal/models/locker.go +++ b/pkg/dal/models/locker.go @@ -15,15 +15,13 @@ package models import ( - "time" - "gorm.io/plugin/soft_delete" ) // Locker locker type Locker struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` diff --git a/pkg/dal/models/namespace.go b/pkg/dal/models/namespace.go index d69403d5..f5b79264 100644 --- a/pkg/dal/models/namespace.go +++ b/pkg/dal/models/namespace.go @@ -16,7 +16,6 @@ package models import ( "strings" - "time" "gorm.io/gorm" "gorm.io/plugin/soft_delete" @@ -26,8 +25,8 @@ import ( // Namespace represents a namespace type Namespace struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` diff --git a/pkg/dal/models/namespace_member.go b/pkg/dal/models/namespace_member.go index 31af3035..a7b93b43 100644 --- a/pkg/dal/models/namespace_member.go +++ b/pkg/dal/models/namespace_member.go @@ -15,8 +15,6 @@ package models import ( - "time" - "gorm.io/plugin/soft_delete" "github.com/go-sigma/sigma/pkg/types/enums" @@ -24,8 +22,8 @@ import ( // NamespaceMember represents namespace role type NamespaceMember struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` diff --git a/pkg/dal/models/reference.go b/pkg/dal/models/reference.go deleted file mode 100644 index 56ec3388..00000000 --- a/pkg/dal/models/reference.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2023 sigma -// -// 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 -// -// http://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 models - -// // Reference is the model for reference. -// type Reference struct { -// Artifact *Artifact -// Tag []*Tag -// } diff --git a/pkg/dal/models/repository.go b/pkg/dal/models/repository.go index 708eae21..6ee4f47f 100644 --- a/pkg/dal/models/repository.go +++ b/pkg/dal/models/repository.go @@ -15,8 +15,6 @@ package models import ( - "time" - "gorm.io/gorm" "gorm.io/plugin/soft_delete" @@ -26,8 +24,8 @@ import ( // Repository represents a repository type Repository struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` diff --git a/pkg/dal/models/setting.go b/pkg/dal/models/setting.go index c24721b8..081a9971 100644 --- a/pkg/dal/models/setting.go +++ b/pkg/dal/models/setting.go @@ -15,15 +15,13 @@ package models import ( - "time" - "gorm.io/plugin/soft_delete" ) // Setting setting type Setting struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` diff --git a/pkg/dal/models/tag.go b/pkg/dal/models/tag.go index c2f94999..0c668878 100644 --- a/pkg/dal/models/tag.go +++ b/pkg/dal/models/tag.go @@ -26,8 +26,8 @@ import ( // Tag represents a tag type Tag struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` diff --git a/pkg/dal/models/user.go b/pkg/dal/models/user.go index 30a3f175..6843c3fb 100644 --- a/pkg/dal/models/user.go +++ b/pkg/dal/models/user.go @@ -24,8 +24,8 @@ import ( // User is the model for the user table. type User struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` @@ -41,8 +41,8 @@ type User struct { // User3rdParty ... type User3rdParty struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` @@ -65,8 +65,8 @@ func (User3rdParty) TableName() string { } type UserRecoverCode struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` diff --git a/pkg/dal/models/webhook.go b/pkg/dal/models/webhook.go index 141c7cc9..8ea956ca 100644 --- a/pkg/dal/models/webhook.go +++ b/pkg/dal/models/webhook.go @@ -15,8 +15,6 @@ package models import ( - "time" - "gorm.io/plugin/soft_delete" "github.com/go-sigma/sigma/pkg/types/enums" @@ -24,8 +22,8 @@ import ( // Webhook ... type Webhook struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` @@ -45,8 +43,8 @@ type Webhook struct { // WebhookLog ... type WebhookLog struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` diff --git a/pkg/dal/models/workq.go b/pkg/dal/models/workq.go index f8eab60a..bd3cab83 100644 --- a/pkg/dal/models/workq.go +++ b/pkg/dal/models/workq.go @@ -15,8 +15,6 @@ package models import ( - "time" - "gorm.io/plugin/soft_delete" "github.com/go-sigma/sigma/pkg/types/enums" @@ -24,8 +22,8 @@ import ( // WorkQueue ... type WorkQueue struct { - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt int64 `gorm:"autoUpdateTime:milli"` + UpdatedAt int64 `gorm:"autoUpdateTime:milli"` DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` ID int64 `gorm:"primaryKey"` diff --git a/pkg/dal/query/artifact_sboms.gen.go b/pkg/dal/query/artifact_sboms.gen.go index 988011d3..b877d275 100644 --- a/pkg/dal/query/artifact_sboms.gen.go +++ b/pkg/dal/query/artifact_sboms.gen.go @@ -27,9 +27,9 @@ func newArtifactSbom(db *gorm.DB, opts ...gen.DOOption) artifactSbom { tableName := _artifactSbom.artifactSbomDo.TableName() _artifactSbom.ALL = field.NewAsterisk(tableName) - _artifactSbom.CreatedAt = field.NewTime(tableName, "created_at") - _artifactSbom.UpdatedAt = field.NewTime(tableName, "updated_at") - _artifactSbom.DeletedAt = field.NewUint(tableName, "deleted_at") + _artifactSbom.CreatedAt = field.NewInt64(tableName, "created_at") + _artifactSbom.UpdatedAt = field.NewInt64(tableName, "updated_at") + _artifactSbom.DeletedAt = field.NewUint64(tableName, "deleted_at") _artifactSbom.ID = field.NewInt64(tableName, "id") _artifactSbom.ArtifactID = field.NewInt64(tableName, "artifact_id") _artifactSbom.Raw = field.NewBytes(tableName, "raw") @@ -155,9 +155,9 @@ type artifactSbom struct { artifactSbomDo artifactSbomDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 ArtifactID field.Int64 Raw field.Bytes @@ -183,9 +183,9 @@ func (a artifactSbom) As(alias string) *artifactSbom { func (a *artifactSbom) updateTableName(table string) *artifactSbom { a.ALL = field.NewAsterisk(table) - a.CreatedAt = field.NewTime(table, "created_at") - a.UpdatedAt = field.NewTime(table, "updated_at") - a.DeletedAt = field.NewUint(table, "deleted_at") + a.CreatedAt = field.NewInt64(table, "created_at") + a.UpdatedAt = field.NewInt64(table, "updated_at") + a.DeletedAt = field.NewUint64(table, "deleted_at") a.ID = field.NewInt64(table, "id") a.ArtifactID = field.NewInt64(table, "artifact_id") a.Raw = field.NewBytes(table, "raw") diff --git a/pkg/dal/query/artifact_vulnerabilities.gen.go b/pkg/dal/query/artifact_vulnerabilities.gen.go index 22f84c89..5bc9b77b 100644 --- a/pkg/dal/query/artifact_vulnerabilities.gen.go +++ b/pkg/dal/query/artifact_vulnerabilities.gen.go @@ -27,9 +27,9 @@ func newArtifactVulnerability(db *gorm.DB, opts ...gen.DOOption) artifactVulnera tableName := _artifactVulnerability.artifactVulnerabilityDo.TableName() _artifactVulnerability.ALL = field.NewAsterisk(tableName) - _artifactVulnerability.CreatedAt = field.NewTime(tableName, "created_at") - _artifactVulnerability.UpdatedAt = field.NewTime(tableName, "updated_at") - _artifactVulnerability.DeletedAt = field.NewUint(tableName, "deleted_at") + _artifactVulnerability.CreatedAt = field.NewInt64(tableName, "created_at") + _artifactVulnerability.UpdatedAt = field.NewInt64(tableName, "updated_at") + _artifactVulnerability.DeletedAt = field.NewUint64(tableName, "deleted_at") _artifactVulnerability.ID = field.NewInt64(tableName, "id") _artifactVulnerability.ArtifactID = field.NewInt64(tableName, "artifact_id") _artifactVulnerability.Metadata = field.NewBytes(tableName, "metadata") @@ -156,9 +156,9 @@ type artifactVulnerability struct { artifactVulnerabilityDo artifactVulnerabilityDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 ArtifactID field.Int64 Metadata field.Bytes @@ -185,9 +185,9 @@ func (a artifactVulnerability) As(alias string) *artifactVulnerability { func (a *artifactVulnerability) updateTableName(table string) *artifactVulnerability { a.ALL = field.NewAsterisk(table) - a.CreatedAt = field.NewTime(table, "created_at") - a.UpdatedAt = field.NewTime(table, "updated_at") - a.DeletedAt = field.NewUint(table, "deleted_at") + a.CreatedAt = field.NewInt64(table, "created_at") + a.UpdatedAt = field.NewInt64(table, "updated_at") + a.DeletedAt = field.NewUint64(table, "deleted_at") a.ID = field.NewInt64(table, "id") a.ArtifactID = field.NewInt64(table, "artifact_id") a.Metadata = field.NewBytes(table, "metadata") diff --git a/pkg/dal/query/artifacts.gen.go b/pkg/dal/query/artifacts.gen.go index 5e5e778e..164de8e4 100644 --- a/pkg/dal/query/artifacts.gen.go +++ b/pkg/dal/query/artifacts.gen.go @@ -28,9 +28,9 @@ func newArtifact(db *gorm.DB, opts ...gen.DOOption) artifact { tableName := _artifact.artifactDo.TableName() _artifact.ALL = field.NewAsterisk(tableName) - _artifact.CreatedAt = field.NewTime(tableName, "created_at") - _artifact.UpdatedAt = field.NewTime(tableName, "updated_at") - _artifact.DeletedAt = field.NewUint(tableName, "deleted_at") + _artifact.CreatedAt = field.NewInt64(tableName, "created_at") + _artifact.UpdatedAt = field.NewInt64(tableName, "updated_at") + _artifact.DeletedAt = field.NewUint64(tableName, "deleted_at") _artifact.ID = field.NewInt64(tableName, "id") _artifact.RepositoryID = field.NewInt64(tableName, "repository_id") _artifact.Digest = field.NewString(tableName, "digest") @@ -237,9 +237,9 @@ type artifact struct { artifactDo artifactDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 RepositoryID field.Int64 Digest field.String @@ -283,9 +283,9 @@ func (a artifact) As(alias string) *artifact { func (a *artifact) updateTableName(table string) *artifact { a.ALL = field.NewAsterisk(table) - a.CreatedAt = field.NewTime(table, "created_at") - a.UpdatedAt = field.NewTime(table, "updated_at") - a.DeletedAt = field.NewUint(table, "deleted_at") + a.CreatedAt = field.NewInt64(table, "created_at") + a.UpdatedAt = field.NewInt64(table, "updated_at") + a.DeletedAt = field.NewUint64(table, "deleted_at") a.ID = field.NewInt64(table, "id") a.RepositoryID = field.NewInt64(table, "repository_id") a.Digest = field.NewString(table, "digest") diff --git a/pkg/dal/query/audits.gen.go b/pkg/dal/query/audits.gen.go index 69a56ae1..740ae5b4 100644 --- a/pkg/dal/query/audits.gen.go +++ b/pkg/dal/query/audits.gen.go @@ -27,9 +27,9 @@ func newAudit(db *gorm.DB, opts ...gen.DOOption) audit { tableName := _audit.auditDo.TableName() _audit.ALL = field.NewAsterisk(tableName) - _audit.CreatedAt = field.NewTime(tableName, "created_at") - _audit.UpdatedAt = field.NewTime(tableName, "updated_at") - _audit.DeletedAt = field.NewUint(tableName, "deleted_at") + _audit.CreatedAt = field.NewInt64(tableName, "created_at") + _audit.UpdatedAt = field.NewInt64(tableName, "updated_at") + _audit.DeletedAt = field.NewUint64(tableName, "deleted_at") _audit.ID = field.NewInt64(tableName, "id") _audit.UserID = field.NewInt64(tableName, "user_id") _audit.NamespaceID = field.NewInt64(tableName, "namespace_id") @@ -59,9 +59,9 @@ type audit struct { auditDo auditDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 UserID field.Int64 NamespaceID field.Int64 @@ -89,9 +89,9 @@ func (a audit) As(alias string) *audit { func (a *audit) updateTableName(table string) *audit { a.ALL = field.NewAsterisk(table) - a.CreatedAt = field.NewTime(table, "created_at") - a.UpdatedAt = field.NewTime(table, "updated_at") - a.DeletedAt = field.NewUint(table, "deleted_at") + a.CreatedAt = field.NewInt64(table, "created_at") + a.UpdatedAt = field.NewInt64(table, "updated_at") + a.DeletedAt = field.NewUint64(table, "deleted_at") a.ID = field.NewInt64(table, "id") a.UserID = field.NewInt64(table, "user_id") a.NamespaceID = field.NewInt64(table, "namespace_id") diff --git a/pkg/dal/query/blob_uploads.gen.go b/pkg/dal/query/blob_uploads.gen.go index fe5dd702..19c0f2d1 100644 --- a/pkg/dal/query/blob_uploads.gen.go +++ b/pkg/dal/query/blob_uploads.gen.go @@ -27,9 +27,9 @@ func newBlobUpload(db *gorm.DB, opts ...gen.DOOption) blobUpload { tableName := _blobUpload.blobUploadDo.TableName() _blobUpload.ALL = field.NewAsterisk(tableName) - _blobUpload.CreatedAt = field.NewTime(tableName, "created_at") - _blobUpload.UpdatedAt = field.NewTime(tableName, "updated_at") - _blobUpload.DeletedAt = field.NewUint(tableName, "deleted_at") + _blobUpload.CreatedAt = field.NewInt64(tableName, "created_at") + _blobUpload.UpdatedAt = field.NewInt64(tableName, "updated_at") + _blobUpload.DeletedAt = field.NewUint64(tableName, "deleted_at") _blobUpload.ID = field.NewInt64(tableName, "id") _blobUpload.PartNumber = field.NewInt(tableName, "part_number") _blobUpload.UploadID = field.NewString(tableName, "upload_id") @@ -47,9 +47,9 @@ type blobUpload struct { blobUploadDo blobUploadDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 PartNumber field.Int UploadID field.String @@ -73,9 +73,9 @@ func (b blobUpload) As(alias string) *blobUpload { func (b *blobUpload) updateTableName(table string) *blobUpload { b.ALL = field.NewAsterisk(table) - b.CreatedAt = field.NewTime(table, "created_at") - b.UpdatedAt = field.NewTime(table, "updated_at") - b.DeletedAt = field.NewUint(table, "deleted_at") + b.CreatedAt = field.NewInt64(table, "created_at") + b.UpdatedAt = field.NewInt64(table, "updated_at") + b.DeletedAt = field.NewUint64(table, "deleted_at") b.ID = field.NewInt64(table, "id") b.PartNumber = field.NewInt(table, "part_number") b.UploadID = field.NewString(table, "upload_id") diff --git a/pkg/dal/query/blobs.gen.go b/pkg/dal/query/blobs.gen.go index 5bc8ac5f..d6368d73 100644 --- a/pkg/dal/query/blobs.gen.go +++ b/pkg/dal/query/blobs.gen.go @@ -28,9 +28,9 @@ func newBlob(db *gorm.DB, opts ...gen.DOOption) blob { tableName := _blob.blobDo.TableName() _blob.ALL = field.NewAsterisk(tableName) - _blob.CreatedAt = field.NewTime(tableName, "created_at") - _blob.UpdatedAt = field.NewTime(tableName, "updated_at") - _blob.DeletedAt = field.NewUint(tableName, "deleted_at") + _blob.CreatedAt = field.NewInt64(tableName, "created_at") + _blob.UpdatedAt = field.NewInt64(tableName, "updated_at") + _blob.DeletedAt = field.NewUint64(tableName, "deleted_at") _blob.ID = field.NewInt64(tableName, "id") _blob.Digest = field.NewString(tableName, "digest") _blob.Size = field.NewInt64(tableName, "size") @@ -155,9 +155,9 @@ type blob struct { blobDo blobDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 Digest field.String Size field.Int64 @@ -182,9 +182,9 @@ func (b blob) As(alias string) *blob { func (b *blob) updateTableName(table string) *blob { b.ALL = field.NewAsterisk(table) - b.CreatedAt = field.NewTime(table, "created_at") - b.UpdatedAt = field.NewTime(table, "updated_at") - b.DeletedAt = field.NewUint(table, "deleted_at") + b.CreatedAt = field.NewInt64(table, "created_at") + b.UpdatedAt = field.NewInt64(table, "updated_at") + b.DeletedAt = field.NewUint64(table, "deleted_at") b.ID = field.NewInt64(table, "id") b.Digest = field.NewString(table, "digest") b.Size = field.NewInt64(table, "size") diff --git a/pkg/dal/query/builder_runners.gen.go b/pkg/dal/query/builder_runners.gen.go index 77b8e268..5fb73f0e 100644 --- a/pkg/dal/query/builder_runners.gen.go +++ b/pkg/dal/query/builder_runners.gen.go @@ -27,9 +27,9 @@ func newBuilderRunner(db *gorm.DB, opts ...gen.DOOption) builderRunner { tableName := _builderRunner.builderRunnerDo.TableName() _builderRunner.ALL = field.NewAsterisk(tableName) - _builderRunner.CreatedAt = field.NewTime(tableName, "created_at") - _builderRunner.UpdatedAt = field.NewTime(tableName, "updated_at") - _builderRunner.DeletedAt = field.NewUint(tableName, "deleted_at") + _builderRunner.CreatedAt = field.NewInt64(tableName, "created_at") + _builderRunner.UpdatedAt = field.NewInt64(tableName, "updated_at") + _builderRunner.DeletedAt = field.NewUint64(tableName, "deleted_at") _builderRunner.ID = field.NewInt64(tableName, "id") _builderRunner.BuilderID = field.NewInt64(tableName, "builder_id") _builderRunner.Log = field.NewBytes(tableName, "log") @@ -77,9 +77,9 @@ type builderRunner struct { builderRunnerDo builderRunnerDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 BuilderID field.Int64 Log field.Bytes @@ -108,9 +108,9 @@ func (b builderRunner) As(alias string) *builderRunner { func (b *builderRunner) updateTableName(table string) *builderRunner { b.ALL = field.NewAsterisk(table) - b.CreatedAt = field.NewTime(table, "created_at") - b.UpdatedAt = field.NewTime(table, "updated_at") - b.DeletedAt = field.NewUint(table, "deleted_at") + b.CreatedAt = field.NewInt64(table, "created_at") + b.UpdatedAt = field.NewInt64(table, "updated_at") + b.DeletedAt = field.NewUint64(table, "deleted_at") b.ID = field.NewInt64(table, "id") b.BuilderID = field.NewInt64(table, "builder_id") b.Log = field.NewBytes(table, "log") diff --git a/pkg/dal/query/builders.gen.go b/pkg/dal/query/builders.gen.go index 51fa034f..1a9f5a79 100644 --- a/pkg/dal/query/builders.gen.go +++ b/pkg/dal/query/builders.gen.go @@ -27,9 +27,9 @@ func newBuilder(db *gorm.DB, opts ...gen.DOOption) builder { tableName := _builder.builderDo.TableName() _builder.ALL = field.NewAsterisk(tableName) - _builder.CreatedAt = field.NewTime(tableName, "created_at") - _builder.UpdatedAt = field.NewTime(tableName, "updated_at") - _builder.DeletedAt = field.NewUint(tableName, "deleted_at") + _builder.CreatedAt = field.NewInt64(tableName, "created_at") + _builder.UpdatedAt = field.NewInt64(tableName, "updated_at") + _builder.DeletedAt = field.NewUint64(tableName, "deleted_at") _builder.ID = field.NewInt64(tableName, "id") _builder.RepositoryID = field.NewInt64(tableName, "repository_id") _builder.Source = field.NewField(tableName, "source") @@ -89,9 +89,9 @@ type builder struct { builderDo builderDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 RepositoryID field.Int64 Source field.Field @@ -135,9 +135,9 @@ func (b builder) As(alias string) *builder { func (b *builder) updateTableName(table string) *builder { b.ALL = field.NewAsterisk(table) - b.CreatedAt = field.NewTime(table, "created_at") - b.UpdatedAt = field.NewTime(table, "updated_at") - b.DeletedAt = field.NewUint(table, "deleted_at") + b.CreatedAt = field.NewInt64(table, "created_at") + b.UpdatedAt = field.NewInt64(table, "updated_at") + b.DeletedAt = field.NewUint64(table, "deleted_at") b.ID = field.NewInt64(table, "id") b.RepositoryID = field.NewInt64(table, "repository_id") b.Source = field.NewField(table, "source") diff --git a/pkg/dal/query/caches.gen.go b/pkg/dal/query/caches.gen.go index 49ff1b1b..2004b19b 100644 --- a/pkg/dal/query/caches.gen.go +++ b/pkg/dal/query/caches.gen.go @@ -28,9 +28,9 @@ func newCache(db *gorm.DB, opts ...gen.DOOption) cache { tableName := _cache.cacheDo.TableName() _cache.ALL = field.NewAsterisk(tableName) - _cache.CreatedAt = field.NewTime(tableName, "created_at") - _cache.UpdatedAt = field.NewTime(tableName, "updated_at") - _cache.DeletedAt = field.NewUint(tableName, "deleted_at") + _cache.CreatedAt = field.NewInt64(tableName, "created_at") + _cache.UpdatedAt = field.NewInt64(tableName, "updated_at") + _cache.DeletedAt = field.NewUint64(tableName, "deleted_at") _cache.ID = field.NewInt64(tableName, "id") _cache.Key = field.NewString(tableName, "key") _cache.Val = field.NewBytes(tableName, "val") @@ -44,9 +44,9 @@ type cache struct { cacheDo cacheDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 Key field.String Val field.Bytes @@ -66,9 +66,9 @@ func (c cache) As(alias string) *cache { func (c *cache) updateTableName(table string) *cache { c.ALL = field.NewAsterisk(table) - c.CreatedAt = field.NewTime(table, "created_at") - c.UpdatedAt = field.NewTime(table, "updated_at") - c.DeletedAt = field.NewUint(table, "deleted_at") + c.CreatedAt = field.NewInt64(table, "created_at") + c.UpdatedAt = field.NewInt64(table, "updated_at") + c.DeletedAt = field.NewUint64(table, "deleted_at") c.ID = field.NewInt64(table, "id") c.Key = field.NewString(table, "key") c.Val = field.NewBytes(table, "val") diff --git a/pkg/dal/query/code_repositories.gen.go b/pkg/dal/query/code_repositories.gen.go index 0d48cf00..f04a01fe 100644 --- a/pkg/dal/query/code_repositories.gen.go +++ b/pkg/dal/query/code_repositories.gen.go @@ -27,9 +27,9 @@ func newCodeRepository(db *gorm.DB, opts ...gen.DOOption) codeRepository { tableName := _codeRepository.codeRepositoryDo.TableName() _codeRepository.ALL = field.NewAsterisk(tableName) - _codeRepository.CreatedAt = field.NewTime(tableName, "created_at") - _codeRepository.UpdatedAt = field.NewTime(tableName, "updated_at") - _codeRepository.DeletedAt = field.NewUint(tableName, "deleted_at") + _codeRepository.CreatedAt = field.NewInt64(tableName, "created_at") + _codeRepository.UpdatedAt = field.NewInt64(tableName, "updated_at") + _codeRepository.DeletedAt = field.NewUint64(tableName, "deleted_at") _codeRepository.ID = field.NewInt64(tableName, "id") _codeRepository.User3rdPartyID = field.NewInt64(tableName, "user_3rdparty_id") _codeRepository.RepositoryID = field.NewString(tableName, "repository_id") @@ -66,9 +66,9 @@ type codeRepository struct { codeRepositoryDo codeRepositoryDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 User3rdPartyID field.Int64 RepositoryID field.String @@ -98,9 +98,9 @@ func (c codeRepository) As(alias string) *codeRepository { func (c *codeRepository) updateTableName(table string) *codeRepository { c.ALL = field.NewAsterisk(table) - c.CreatedAt = field.NewTime(table, "created_at") - c.UpdatedAt = field.NewTime(table, "updated_at") - c.DeletedAt = field.NewUint(table, "deleted_at") + c.CreatedAt = field.NewInt64(table, "created_at") + c.UpdatedAt = field.NewInt64(table, "updated_at") + c.DeletedAt = field.NewUint64(table, "deleted_at") c.ID = field.NewInt64(table, "id") c.User3rdPartyID = field.NewInt64(table, "user_3rdparty_id") c.RepositoryID = field.NewString(table, "repository_id") diff --git a/pkg/dal/query/code_repository_branches.gen.go b/pkg/dal/query/code_repository_branches.gen.go index 920e504b..e3310a87 100644 --- a/pkg/dal/query/code_repository_branches.gen.go +++ b/pkg/dal/query/code_repository_branches.gen.go @@ -27,9 +27,9 @@ func newCodeRepositoryBranch(db *gorm.DB, opts ...gen.DOOption) codeRepositoryBr tableName := _codeRepositoryBranch.codeRepositoryBranchDo.TableName() _codeRepositoryBranch.ALL = field.NewAsterisk(tableName) - _codeRepositoryBranch.CreatedAt = field.NewTime(tableName, "created_at") - _codeRepositoryBranch.UpdatedAt = field.NewTime(tableName, "updated_at") - _codeRepositoryBranch.DeletedAt = field.NewUint(tableName, "deleted_at") + _codeRepositoryBranch.CreatedAt = field.NewInt64(tableName, "created_at") + _codeRepositoryBranch.UpdatedAt = field.NewInt64(tableName, "updated_at") + _codeRepositoryBranch.DeletedAt = field.NewUint64(tableName, "deleted_at") _codeRepositoryBranch.ID = field.NewInt64(tableName, "id") _codeRepositoryBranch.CodeRepositoryID = field.NewInt64(tableName, "code_repository_id") _codeRepositoryBranch.Name = field.NewString(tableName, "name") @@ -43,9 +43,9 @@ type codeRepositoryBranch struct { codeRepositoryBranchDo codeRepositoryBranchDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 CodeRepositoryID field.Int64 Name field.String @@ -65,9 +65,9 @@ func (c codeRepositoryBranch) As(alias string) *codeRepositoryBranch { func (c *codeRepositoryBranch) updateTableName(table string) *codeRepositoryBranch { c.ALL = field.NewAsterisk(table) - c.CreatedAt = field.NewTime(table, "created_at") - c.UpdatedAt = field.NewTime(table, "updated_at") - c.DeletedAt = field.NewUint(table, "deleted_at") + c.CreatedAt = field.NewInt64(table, "created_at") + c.UpdatedAt = field.NewInt64(table, "updated_at") + c.DeletedAt = field.NewUint64(table, "deleted_at") c.ID = field.NewInt64(table, "id") c.CodeRepositoryID = field.NewInt64(table, "code_repository_id") c.Name = field.NewString(table, "name") diff --git a/pkg/dal/query/code_repository_clone_credentials.gen.go b/pkg/dal/query/code_repository_clone_credentials.gen.go index 2da50b86..43889272 100644 --- a/pkg/dal/query/code_repository_clone_credentials.gen.go +++ b/pkg/dal/query/code_repository_clone_credentials.gen.go @@ -27,9 +27,9 @@ func newCodeRepositoryCloneCredential(db *gorm.DB, opts ...gen.DOOption) codeRep tableName := _codeRepositoryCloneCredential.codeRepositoryCloneCredentialDo.TableName() _codeRepositoryCloneCredential.ALL = field.NewAsterisk(tableName) - _codeRepositoryCloneCredential.CreatedAt = field.NewTime(tableName, "created_at") - _codeRepositoryCloneCredential.UpdatedAt = field.NewTime(tableName, "updated_at") - _codeRepositoryCloneCredential.DeletedAt = field.NewUint(tableName, "deleted_at") + _codeRepositoryCloneCredential.CreatedAt = field.NewInt64(tableName, "created_at") + _codeRepositoryCloneCredential.UpdatedAt = field.NewInt64(tableName, "updated_at") + _codeRepositoryCloneCredential.DeletedAt = field.NewUint64(tableName, "deleted_at") _codeRepositoryCloneCredential.ID = field.NewInt64(tableName, "id") _codeRepositoryCloneCredential.User3rdPartyID = field.NewInt64(tableName, "user_3rdparty_id") _codeRepositoryCloneCredential.Type = field.NewField(tableName, "type") @@ -57,9 +57,9 @@ type codeRepositoryCloneCredential struct { codeRepositoryCloneCredentialDo codeRepositoryCloneCredentialDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 User3rdPartyID field.Int64 Type field.Field @@ -84,9 +84,9 @@ func (c codeRepositoryCloneCredential) As(alias string) *codeRepositoryCloneCred func (c *codeRepositoryCloneCredential) updateTableName(table string) *codeRepositoryCloneCredential { c.ALL = field.NewAsterisk(table) - c.CreatedAt = field.NewTime(table, "created_at") - c.UpdatedAt = field.NewTime(table, "updated_at") - c.DeletedAt = field.NewUint(table, "deleted_at") + c.CreatedAt = field.NewInt64(table, "created_at") + c.UpdatedAt = field.NewInt64(table, "updated_at") + c.DeletedAt = field.NewUint64(table, "deleted_at") c.ID = field.NewInt64(table, "id") c.User3rdPartyID = field.NewInt64(table, "user_3rdparty_id") c.Type = field.NewField(table, "type") diff --git a/pkg/dal/query/code_repository_owners.gen.go b/pkg/dal/query/code_repository_owners.gen.go index ca8e951c..c4d37dd5 100644 --- a/pkg/dal/query/code_repository_owners.gen.go +++ b/pkg/dal/query/code_repository_owners.gen.go @@ -27,9 +27,9 @@ func newCodeRepositoryOwner(db *gorm.DB, opts ...gen.DOOption) codeRepositoryOwn tableName := _codeRepositoryOwner.codeRepositoryOwnerDo.TableName() _codeRepositoryOwner.ALL = field.NewAsterisk(tableName) - _codeRepositoryOwner.CreatedAt = field.NewTime(tableName, "created_at") - _codeRepositoryOwner.UpdatedAt = field.NewTime(tableName, "updated_at") - _codeRepositoryOwner.DeletedAt = field.NewUint(tableName, "deleted_at") + _codeRepositoryOwner.CreatedAt = field.NewInt64(tableName, "created_at") + _codeRepositoryOwner.UpdatedAt = field.NewInt64(tableName, "updated_at") + _codeRepositoryOwner.DeletedAt = field.NewUint64(tableName, "deleted_at") _codeRepositoryOwner.ID = field.NewInt64(tableName, "id") _codeRepositoryOwner.User3rdPartyID = field.NewInt64(tableName, "user_3rdparty_id") _codeRepositoryOwner.OwnerID = field.NewString(tableName, "owner_id") @@ -55,9 +55,9 @@ type codeRepositoryOwner struct { codeRepositoryOwnerDo codeRepositoryOwnerDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 User3rdPartyID field.Int64 OwnerID field.String @@ -80,9 +80,9 @@ func (c codeRepositoryOwner) As(alias string) *codeRepositoryOwner { func (c *codeRepositoryOwner) updateTableName(table string) *codeRepositoryOwner { c.ALL = field.NewAsterisk(table) - c.CreatedAt = field.NewTime(table, "created_at") - c.UpdatedAt = field.NewTime(table, "updated_at") - c.DeletedAt = field.NewUint(table, "deleted_at") + c.CreatedAt = field.NewInt64(table, "created_at") + c.UpdatedAt = field.NewInt64(table, "updated_at") + c.DeletedAt = field.NewUint64(table, "deleted_at") c.ID = field.NewInt64(table, "id") c.User3rdPartyID = field.NewInt64(table, "user_3rdparty_id") c.OwnerID = field.NewString(table, "owner_id") diff --git a/pkg/dal/query/daemon_gc_artifact_records.gen.go b/pkg/dal/query/daemon_gc_artifact_records.gen.go index 6b15d4f0..6e7bfe36 100644 --- a/pkg/dal/query/daemon_gc_artifact_records.gen.go +++ b/pkg/dal/query/daemon_gc_artifact_records.gen.go @@ -27,9 +27,9 @@ func newDaemonGcArtifactRecord(db *gorm.DB, opts ...gen.DOOption) daemonGcArtifa tableName := _daemonGcArtifactRecord.daemonGcArtifactRecordDo.TableName() _daemonGcArtifactRecord.ALL = field.NewAsterisk(tableName) - _daemonGcArtifactRecord.CreatedAt = field.NewTime(tableName, "created_at") - _daemonGcArtifactRecord.UpdatedAt = field.NewTime(tableName, "updated_at") - _daemonGcArtifactRecord.DeletedAt = field.NewUint(tableName, "deleted_at") + _daemonGcArtifactRecord.CreatedAt = field.NewInt64(tableName, "created_at") + _daemonGcArtifactRecord.UpdatedAt = field.NewInt64(tableName, "updated_at") + _daemonGcArtifactRecord.DeletedAt = field.NewUint64(tableName, "deleted_at") _daemonGcArtifactRecord.ID = field.NewInt64(tableName, "id") _daemonGcArtifactRecord.RunnerID = field.NewInt64(tableName, "runner_id") _daemonGcArtifactRecord.Digest = field.NewString(tableName, "digest") @@ -63,9 +63,9 @@ type daemonGcArtifactRecord struct { daemonGcArtifactRecordDo daemonGcArtifactRecordDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 RunnerID field.Int64 Digest field.String @@ -88,9 +88,9 @@ func (d daemonGcArtifactRecord) As(alias string) *daemonGcArtifactRecord { func (d *daemonGcArtifactRecord) updateTableName(table string) *daemonGcArtifactRecord { d.ALL = field.NewAsterisk(table) - d.CreatedAt = field.NewTime(table, "created_at") - d.UpdatedAt = field.NewTime(table, "updated_at") - d.DeletedAt = field.NewUint(table, "deleted_at") + d.CreatedAt = field.NewInt64(table, "created_at") + d.UpdatedAt = field.NewInt64(table, "updated_at") + d.DeletedAt = field.NewUint64(table, "deleted_at") d.ID = field.NewInt64(table, "id") d.RunnerID = field.NewInt64(table, "runner_id") d.Digest = field.NewString(table, "digest") diff --git a/pkg/dal/query/daemon_gc_artifact_rules.gen.go b/pkg/dal/query/daemon_gc_artifact_rules.gen.go index d7b5d8e4..5040ee25 100644 --- a/pkg/dal/query/daemon_gc_artifact_rules.gen.go +++ b/pkg/dal/query/daemon_gc_artifact_rules.gen.go @@ -27,9 +27,9 @@ func newDaemonGcArtifactRule(db *gorm.DB, opts ...gen.DOOption) daemonGcArtifact tableName := _daemonGcArtifactRule.daemonGcArtifactRuleDo.TableName() _daemonGcArtifactRule.ALL = field.NewAsterisk(tableName) - _daemonGcArtifactRule.CreatedAt = field.NewTime(tableName, "created_at") - _daemonGcArtifactRule.UpdatedAt = field.NewTime(tableName, "updated_at") - _daemonGcArtifactRule.DeletedAt = field.NewUint(tableName, "deleted_at") + _daemonGcArtifactRule.CreatedAt = field.NewInt64(tableName, "created_at") + _daemonGcArtifactRule.UpdatedAt = field.NewInt64(tableName, "updated_at") + _daemonGcArtifactRule.DeletedAt = field.NewUint64(tableName, "deleted_at") _daemonGcArtifactRule.ID = field.NewInt64(tableName, "id") _daemonGcArtifactRule.NamespaceID = field.NewInt64(tableName, "namespace_id") _daemonGcArtifactRule.IsRunning = field.NewBool(tableName, "is_running") @@ -52,9 +52,9 @@ type daemonGcArtifactRule struct { daemonGcArtifactRuleDo daemonGcArtifactRuleDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 NamespaceID field.Int64 IsRunning field.Bool @@ -79,9 +79,9 @@ func (d daemonGcArtifactRule) As(alias string) *daemonGcArtifactRule { func (d *daemonGcArtifactRule) updateTableName(table string) *daemonGcArtifactRule { d.ALL = field.NewAsterisk(table) - d.CreatedAt = field.NewTime(table, "created_at") - d.UpdatedAt = field.NewTime(table, "updated_at") - d.DeletedAt = field.NewUint(table, "deleted_at") + d.CreatedAt = field.NewInt64(table, "created_at") + d.UpdatedAt = field.NewInt64(table, "updated_at") + d.DeletedAt = field.NewUint64(table, "deleted_at") d.ID = field.NewInt64(table, "id") d.NamespaceID = field.NewInt64(table, "namespace_id") d.IsRunning = field.NewBool(table, "is_running") diff --git a/pkg/dal/query/daemon_gc_artifact_runners.gen.go b/pkg/dal/query/daemon_gc_artifact_runners.gen.go index 686f5d24..1d3367fa 100644 --- a/pkg/dal/query/daemon_gc_artifact_runners.gen.go +++ b/pkg/dal/query/daemon_gc_artifact_runners.gen.go @@ -27,9 +27,9 @@ func newDaemonGcArtifactRunner(db *gorm.DB, opts ...gen.DOOption) daemonGcArtifa tableName := _daemonGcArtifactRunner.daemonGcArtifactRunnerDo.TableName() _daemonGcArtifactRunner.ALL = field.NewAsterisk(tableName) - _daemonGcArtifactRunner.CreatedAt = field.NewTime(tableName, "created_at") - _daemonGcArtifactRunner.UpdatedAt = field.NewTime(tableName, "updated_at") - _daemonGcArtifactRunner.DeletedAt = field.NewUint(tableName, "deleted_at") + _daemonGcArtifactRunner.CreatedAt = field.NewInt64(tableName, "created_at") + _daemonGcArtifactRunner.UpdatedAt = field.NewInt64(tableName, "updated_at") + _daemonGcArtifactRunner.DeletedAt = field.NewUint64(tableName, "deleted_at") _daemonGcArtifactRunner.ID = field.NewInt64(tableName, "id") _daemonGcArtifactRunner.RuleID = field.NewInt64(tableName, "rule_id") _daemonGcArtifactRunner.Status = field.NewField(tableName, "status") @@ -59,9 +59,9 @@ type daemonGcArtifactRunner struct { daemonGcArtifactRunnerDo daemonGcArtifactRunnerDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 RuleID field.Int64 Status field.Field @@ -88,9 +88,9 @@ func (d daemonGcArtifactRunner) As(alias string) *daemonGcArtifactRunner { func (d *daemonGcArtifactRunner) updateTableName(table string) *daemonGcArtifactRunner { d.ALL = field.NewAsterisk(table) - d.CreatedAt = field.NewTime(table, "created_at") - d.UpdatedAt = field.NewTime(table, "updated_at") - d.DeletedAt = field.NewUint(table, "deleted_at") + d.CreatedAt = field.NewInt64(table, "created_at") + d.UpdatedAt = field.NewInt64(table, "updated_at") + d.DeletedAt = field.NewUint64(table, "deleted_at") d.ID = field.NewInt64(table, "id") d.RuleID = field.NewInt64(table, "rule_id") d.Status = field.NewField(table, "status") diff --git a/pkg/dal/query/daemon_gc_blob_records.gen.go b/pkg/dal/query/daemon_gc_blob_records.gen.go index be529556..2cd39f0e 100644 --- a/pkg/dal/query/daemon_gc_blob_records.gen.go +++ b/pkg/dal/query/daemon_gc_blob_records.gen.go @@ -27,9 +27,9 @@ func newDaemonGcBlobRecord(db *gorm.DB, opts ...gen.DOOption) daemonGcBlobRecord tableName := _daemonGcBlobRecord.daemonGcBlobRecordDo.TableName() _daemonGcBlobRecord.ALL = field.NewAsterisk(tableName) - _daemonGcBlobRecord.CreatedAt = field.NewTime(tableName, "created_at") - _daemonGcBlobRecord.UpdatedAt = field.NewTime(tableName, "updated_at") - _daemonGcBlobRecord.DeletedAt = field.NewUint(tableName, "deleted_at") + _daemonGcBlobRecord.CreatedAt = field.NewInt64(tableName, "created_at") + _daemonGcBlobRecord.UpdatedAt = field.NewInt64(tableName, "updated_at") + _daemonGcBlobRecord.DeletedAt = field.NewUint64(tableName, "deleted_at") _daemonGcBlobRecord.ID = field.NewInt64(tableName, "id") _daemonGcBlobRecord.RunnerID = field.NewInt64(tableName, "runner_id") _daemonGcBlobRecord.Digest = field.NewString(tableName, "digest") @@ -55,9 +55,9 @@ type daemonGcBlobRecord struct { daemonGcBlobRecordDo daemonGcBlobRecordDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 RunnerID field.Int64 Digest field.String @@ -80,9 +80,9 @@ func (d daemonGcBlobRecord) As(alias string) *daemonGcBlobRecord { func (d *daemonGcBlobRecord) updateTableName(table string) *daemonGcBlobRecord { d.ALL = field.NewAsterisk(table) - d.CreatedAt = field.NewTime(table, "created_at") - d.UpdatedAt = field.NewTime(table, "updated_at") - d.DeletedAt = field.NewUint(table, "deleted_at") + d.CreatedAt = field.NewInt64(table, "created_at") + d.UpdatedAt = field.NewInt64(table, "updated_at") + d.DeletedAt = field.NewUint64(table, "deleted_at") d.ID = field.NewInt64(table, "id") d.RunnerID = field.NewInt64(table, "runner_id") d.Digest = field.NewString(table, "digest") diff --git a/pkg/dal/query/daemon_gc_blob_rules.gen.go b/pkg/dal/query/daemon_gc_blob_rules.gen.go index ddedd381..7161fe3e 100644 --- a/pkg/dal/query/daemon_gc_blob_rules.gen.go +++ b/pkg/dal/query/daemon_gc_blob_rules.gen.go @@ -27,9 +27,9 @@ func newDaemonGcBlobRule(db *gorm.DB, opts ...gen.DOOption) daemonGcBlobRule { tableName := _daemonGcBlobRule.daemonGcBlobRuleDo.TableName() _daemonGcBlobRule.ALL = field.NewAsterisk(tableName) - _daemonGcBlobRule.CreatedAt = field.NewTime(tableName, "created_at") - _daemonGcBlobRule.UpdatedAt = field.NewTime(tableName, "updated_at") - _daemonGcBlobRule.DeletedAt = field.NewUint(tableName, "deleted_at") + _daemonGcBlobRule.CreatedAt = field.NewInt64(tableName, "created_at") + _daemonGcBlobRule.UpdatedAt = field.NewInt64(tableName, "updated_at") + _daemonGcBlobRule.DeletedAt = field.NewUint64(tableName, "deleted_at") _daemonGcBlobRule.ID = field.NewInt64(tableName, "id") _daemonGcBlobRule.IsRunning = field.NewBool(tableName, "is_running") _daemonGcBlobRule.RetentionDay = field.NewInt(tableName, "retention_day") @@ -46,9 +46,9 @@ type daemonGcBlobRule struct { daemonGcBlobRuleDo daemonGcBlobRuleDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 IsRunning field.Bool RetentionDay field.Int @@ -71,9 +71,9 @@ func (d daemonGcBlobRule) As(alias string) *daemonGcBlobRule { func (d *daemonGcBlobRule) updateTableName(table string) *daemonGcBlobRule { d.ALL = field.NewAsterisk(table) - d.CreatedAt = field.NewTime(table, "created_at") - d.UpdatedAt = field.NewTime(table, "updated_at") - d.DeletedAt = field.NewUint(table, "deleted_at") + d.CreatedAt = field.NewInt64(table, "created_at") + d.UpdatedAt = field.NewInt64(table, "updated_at") + d.DeletedAt = field.NewUint64(table, "deleted_at") d.ID = field.NewInt64(table, "id") d.IsRunning = field.NewBool(table, "is_running") d.RetentionDay = field.NewInt(table, "retention_day") diff --git a/pkg/dal/query/daemon_gc_blob_runners.gen.go b/pkg/dal/query/daemon_gc_blob_runners.gen.go index 42aafa6d..9c7f3910 100644 --- a/pkg/dal/query/daemon_gc_blob_runners.gen.go +++ b/pkg/dal/query/daemon_gc_blob_runners.gen.go @@ -27,9 +27,9 @@ func newDaemonGcBlobRunner(db *gorm.DB, opts ...gen.DOOption) daemonGcBlobRunner tableName := _daemonGcBlobRunner.daemonGcBlobRunnerDo.TableName() _daemonGcBlobRunner.ALL = field.NewAsterisk(tableName) - _daemonGcBlobRunner.CreatedAt = field.NewTime(tableName, "created_at") - _daemonGcBlobRunner.UpdatedAt = field.NewTime(tableName, "updated_at") - _daemonGcBlobRunner.DeletedAt = field.NewUint(tableName, "deleted_at") + _daemonGcBlobRunner.CreatedAt = field.NewInt64(tableName, "created_at") + _daemonGcBlobRunner.UpdatedAt = field.NewInt64(tableName, "updated_at") + _daemonGcBlobRunner.DeletedAt = field.NewUint64(tableName, "deleted_at") _daemonGcBlobRunner.ID = field.NewInt64(tableName, "id") _daemonGcBlobRunner.RuleID = field.NewInt64(tableName, "rule_id") _daemonGcBlobRunner.Status = field.NewField(tableName, "status") @@ -54,9 +54,9 @@ type daemonGcBlobRunner struct { daemonGcBlobRunnerDo daemonGcBlobRunnerDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 RuleID field.Int64 Status field.Field @@ -83,9 +83,9 @@ func (d daemonGcBlobRunner) As(alias string) *daemonGcBlobRunner { func (d *daemonGcBlobRunner) updateTableName(table string) *daemonGcBlobRunner { d.ALL = field.NewAsterisk(table) - d.CreatedAt = field.NewTime(table, "created_at") - d.UpdatedAt = field.NewTime(table, "updated_at") - d.DeletedAt = field.NewUint(table, "deleted_at") + d.CreatedAt = field.NewInt64(table, "created_at") + d.UpdatedAt = field.NewInt64(table, "updated_at") + d.DeletedAt = field.NewUint64(table, "deleted_at") d.ID = field.NewInt64(table, "id") d.RuleID = field.NewInt64(table, "rule_id") d.Status = field.NewField(table, "status") diff --git a/pkg/dal/query/daemon_gc_repository_records.gen.go b/pkg/dal/query/daemon_gc_repository_records.gen.go index 8a6de358..fb08c694 100644 --- a/pkg/dal/query/daemon_gc_repository_records.gen.go +++ b/pkg/dal/query/daemon_gc_repository_records.gen.go @@ -27,9 +27,9 @@ func newDaemonGcRepositoryRecord(db *gorm.DB, opts ...gen.DOOption) daemonGcRepo tableName := _daemonGcRepositoryRecord.daemonGcRepositoryRecordDo.TableName() _daemonGcRepositoryRecord.ALL = field.NewAsterisk(tableName) - _daemonGcRepositoryRecord.CreatedAt = field.NewTime(tableName, "created_at") - _daemonGcRepositoryRecord.UpdatedAt = field.NewTime(tableName, "updated_at") - _daemonGcRepositoryRecord.DeletedAt = field.NewUint(tableName, "deleted_at") + _daemonGcRepositoryRecord.CreatedAt = field.NewInt64(tableName, "created_at") + _daemonGcRepositoryRecord.UpdatedAt = field.NewInt64(tableName, "updated_at") + _daemonGcRepositoryRecord.DeletedAt = field.NewUint64(tableName, "deleted_at") _daemonGcRepositoryRecord.ID = field.NewInt64(tableName, "id") _daemonGcRepositoryRecord.RunnerID = field.NewInt64(tableName, "runner_id") _daemonGcRepositoryRecord.Repository = field.NewString(tableName, "repository") @@ -63,9 +63,9 @@ type daemonGcRepositoryRecord struct { daemonGcRepositoryRecordDo daemonGcRepositoryRecordDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 RunnerID field.Int64 Repository field.String @@ -88,9 +88,9 @@ func (d daemonGcRepositoryRecord) As(alias string) *daemonGcRepositoryRecord { func (d *daemonGcRepositoryRecord) updateTableName(table string) *daemonGcRepositoryRecord { d.ALL = field.NewAsterisk(table) - d.CreatedAt = field.NewTime(table, "created_at") - d.UpdatedAt = field.NewTime(table, "updated_at") - d.DeletedAt = field.NewUint(table, "deleted_at") + d.CreatedAt = field.NewInt64(table, "created_at") + d.UpdatedAt = field.NewInt64(table, "updated_at") + d.DeletedAt = field.NewUint64(table, "deleted_at") d.ID = field.NewInt64(table, "id") d.RunnerID = field.NewInt64(table, "runner_id") d.Repository = field.NewString(table, "repository") diff --git a/pkg/dal/query/daemon_gc_repository_rules.gen.go b/pkg/dal/query/daemon_gc_repository_rules.gen.go index c8d0acef..20d34ade 100644 --- a/pkg/dal/query/daemon_gc_repository_rules.gen.go +++ b/pkg/dal/query/daemon_gc_repository_rules.gen.go @@ -27,9 +27,9 @@ func newDaemonGcRepositoryRule(db *gorm.DB, opts ...gen.DOOption) daemonGcReposi tableName := _daemonGcRepositoryRule.daemonGcRepositoryRuleDo.TableName() _daemonGcRepositoryRule.ALL = field.NewAsterisk(tableName) - _daemonGcRepositoryRule.CreatedAt = field.NewTime(tableName, "created_at") - _daemonGcRepositoryRule.UpdatedAt = field.NewTime(tableName, "updated_at") - _daemonGcRepositoryRule.DeletedAt = field.NewUint(tableName, "deleted_at") + _daemonGcRepositoryRule.CreatedAt = field.NewInt64(tableName, "created_at") + _daemonGcRepositoryRule.UpdatedAt = field.NewInt64(tableName, "updated_at") + _daemonGcRepositoryRule.DeletedAt = field.NewUint64(tableName, "deleted_at") _daemonGcRepositoryRule.ID = field.NewInt64(tableName, "id") _daemonGcRepositoryRule.NamespaceID = field.NewInt64(tableName, "namespace_id") _daemonGcRepositoryRule.IsRunning = field.NewBool(tableName, "is_running") @@ -52,9 +52,9 @@ type daemonGcRepositoryRule struct { daemonGcRepositoryRuleDo daemonGcRepositoryRuleDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 NamespaceID field.Int64 IsRunning field.Bool @@ -79,9 +79,9 @@ func (d daemonGcRepositoryRule) As(alias string) *daemonGcRepositoryRule { func (d *daemonGcRepositoryRule) updateTableName(table string) *daemonGcRepositoryRule { d.ALL = field.NewAsterisk(table) - d.CreatedAt = field.NewTime(table, "created_at") - d.UpdatedAt = field.NewTime(table, "updated_at") - d.DeletedAt = field.NewUint(table, "deleted_at") + d.CreatedAt = field.NewInt64(table, "created_at") + d.UpdatedAt = field.NewInt64(table, "updated_at") + d.DeletedAt = field.NewUint64(table, "deleted_at") d.ID = field.NewInt64(table, "id") d.NamespaceID = field.NewInt64(table, "namespace_id") d.IsRunning = field.NewBool(table, "is_running") diff --git a/pkg/dal/query/daemon_gc_repository_runners.gen.go b/pkg/dal/query/daemon_gc_repository_runners.gen.go index 864e3907..b345c924 100644 --- a/pkg/dal/query/daemon_gc_repository_runners.gen.go +++ b/pkg/dal/query/daemon_gc_repository_runners.gen.go @@ -27,9 +27,9 @@ func newDaemonGcRepositoryRunner(db *gorm.DB, opts ...gen.DOOption) daemonGcRepo tableName := _daemonGcRepositoryRunner.daemonGcRepositoryRunnerDo.TableName() _daemonGcRepositoryRunner.ALL = field.NewAsterisk(tableName) - _daemonGcRepositoryRunner.CreatedAt = field.NewTime(tableName, "created_at") - _daemonGcRepositoryRunner.UpdatedAt = field.NewTime(tableName, "updated_at") - _daemonGcRepositoryRunner.DeletedAt = field.NewUint(tableName, "deleted_at") + _daemonGcRepositoryRunner.CreatedAt = field.NewInt64(tableName, "created_at") + _daemonGcRepositoryRunner.UpdatedAt = field.NewInt64(tableName, "updated_at") + _daemonGcRepositoryRunner.DeletedAt = field.NewUint64(tableName, "deleted_at") _daemonGcRepositoryRunner.ID = field.NewInt64(tableName, "id") _daemonGcRepositoryRunner.RuleID = field.NewInt64(tableName, "rule_id") _daemonGcRepositoryRunner.Status = field.NewField(tableName, "status") @@ -59,9 +59,9 @@ type daemonGcRepositoryRunner struct { daemonGcRepositoryRunnerDo daemonGcRepositoryRunnerDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 RuleID field.Int64 Status field.Field @@ -88,9 +88,9 @@ func (d daemonGcRepositoryRunner) As(alias string) *daemonGcRepositoryRunner { func (d *daemonGcRepositoryRunner) updateTableName(table string) *daemonGcRepositoryRunner { d.ALL = field.NewAsterisk(table) - d.CreatedAt = field.NewTime(table, "created_at") - d.UpdatedAt = field.NewTime(table, "updated_at") - d.DeletedAt = field.NewUint(table, "deleted_at") + d.CreatedAt = field.NewInt64(table, "created_at") + d.UpdatedAt = field.NewInt64(table, "updated_at") + d.DeletedAt = field.NewUint64(table, "deleted_at") d.ID = field.NewInt64(table, "id") d.RuleID = field.NewInt64(table, "rule_id") d.Status = field.NewField(table, "status") diff --git a/pkg/dal/query/daemon_gc_tag_records.gen.go b/pkg/dal/query/daemon_gc_tag_records.gen.go index 417d0bad..b60d1186 100644 --- a/pkg/dal/query/daemon_gc_tag_records.gen.go +++ b/pkg/dal/query/daemon_gc_tag_records.gen.go @@ -27,9 +27,9 @@ func newDaemonGcTagRecord(db *gorm.DB, opts ...gen.DOOption) daemonGcTagRecord { tableName := _daemonGcTagRecord.daemonGcTagRecordDo.TableName() _daemonGcTagRecord.ALL = field.NewAsterisk(tableName) - _daemonGcTagRecord.CreatedAt = field.NewTime(tableName, "created_at") - _daemonGcTagRecord.UpdatedAt = field.NewTime(tableName, "updated_at") - _daemonGcTagRecord.DeletedAt = field.NewUint(tableName, "deleted_at") + _daemonGcTagRecord.CreatedAt = field.NewInt64(tableName, "created_at") + _daemonGcTagRecord.UpdatedAt = field.NewInt64(tableName, "updated_at") + _daemonGcTagRecord.DeletedAt = field.NewUint64(tableName, "deleted_at") _daemonGcTagRecord.ID = field.NewInt64(tableName, "id") _daemonGcTagRecord.RunnerID = field.NewInt64(tableName, "runner_id") _daemonGcTagRecord.Tag = field.NewString(tableName, "tag") @@ -63,9 +63,9 @@ type daemonGcTagRecord struct { daemonGcTagRecordDo daemonGcTagRecordDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 RunnerID field.Int64 Tag field.String @@ -88,9 +88,9 @@ func (d daemonGcTagRecord) As(alias string) *daemonGcTagRecord { func (d *daemonGcTagRecord) updateTableName(table string) *daemonGcTagRecord { d.ALL = field.NewAsterisk(table) - d.CreatedAt = field.NewTime(table, "created_at") - d.UpdatedAt = field.NewTime(table, "updated_at") - d.DeletedAt = field.NewUint(table, "deleted_at") + d.CreatedAt = field.NewInt64(table, "created_at") + d.UpdatedAt = field.NewInt64(table, "updated_at") + d.DeletedAt = field.NewUint64(table, "deleted_at") d.ID = field.NewInt64(table, "id") d.RunnerID = field.NewInt64(table, "runner_id") d.Tag = field.NewString(table, "tag") diff --git a/pkg/dal/query/daemon_gc_tag_rules.gen.go b/pkg/dal/query/daemon_gc_tag_rules.gen.go index fdc321cf..0305f380 100644 --- a/pkg/dal/query/daemon_gc_tag_rules.gen.go +++ b/pkg/dal/query/daemon_gc_tag_rules.gen.go @@ -27,9 +27,9 @@ func newDaemonGcTagRule(db *gorm.DB, opts ...gen.DOOption) daemonGcTagRule { tableName := _daemonGcTagRule.daemonGcTagRuleDo.TableName() _daemonGcTagRule.ALL = field.NewAsterisk(tableName) - _daemonGcTagRule.CreatedAt = field.NewTime(tableName, "created_at") - _daemonGcTagRule.UpdatedAt = field.NewTime(tableName, "updated_at") - _daemonGcTagRule.DeletedAt = field.NewUint(tableName, "deleted_at") + _daemonGcTagRule.CreatedAt = field.NewInt64(tableName, "created_at") + _daemonGcTagRule.UpdatedAt = field.NewInt64(tableName, "updated_at") + _daemonGcTagRule.DeletedAt = field.NewUint64(tableName, "deleted_at") _daemonGcTagRule.ID = field.NewInt64(tableName, "id") _daemonGcTagRule.NamespaceID = field.NewInt64(tableName, "namespace_id") _daemonGcTagRule.IsRunning = field.NewBool(tableName, "is_running") @@ -54,9 +54,9 @@ type daemonGcTagRule struct { daemonGcTagRuleDo daemonGcTagRuleDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 NamespaceID field.Int64 IsRunning field.Bool @@ -83,9 +83,9 @@ func (d daemonGcTagRule) As(alias string) *daemonGcTagRule { func (d *daemonGcTagRule) updateTableName(table string) *daemonGcTagRule { d.ALL = field.NewAsterisk(table) - d.CreatedAt = field.NewTime(table, "created_at") - d.UpdatedAt = field.NewTime(table, "updated_at") - d.DeletedAt = field.NewUint(table, "deleted_at") + d.CreatedAt = field.NewInt64(table, "created_at") + d.UpdatedAt = field.NewInt64(table, "updated_at") + d.DeletedAt = field.NewUint64(table, "deleted_at") d.ID = field.NewInt64(table, "id") d.NamespaceID = field.NewInt64(table, "namespace_id") d.IsRunning = field.NewBool(table, "is_running") diff --git a/pkg/dal/query/daemon_gc_tag_runners.gen.go b/pkg/dal/query/daemon_gc_tag_runners.gen.go index 8764a6f1..0886b4a2 100644 --- a/pkg/dal/query/daemon_gc_tag_runners.gen.go +++ b/pkg/dal/query/daemon_gc_tag_runners.gen.go @@ -27,9 +27,9 @@ func newDaemonGcTagRunner(db *gorm.DB, opts ...gen.DOOption) daemonGcTagRunner { tableName := _daemonGcTagRunner.daemonGcTagRunnerDo.TableName() _daemonGcTagRunner.ALL = field.NewAsterisk(tableName) - _daemonGcTagRunner.CreatedAt = field.NewTime(tableName, "created_at") - _daemonGcTagRunner.UpdatedAt = field.NewTime(tableName, "updated_at") - _daemonGcTagRunner.DeletedAt = field.NewUint(tableName, "deleted_at") + _daemonGcTagRunner.CreatedAt = field.NewInt64(tableName, "created_at") + _daemonGcTagRunner.UpdatedAt = field.NewInt64(tableName, "updated_at") + _daemonGcTagRunner.DeletedAt = field.NewUint64(tableName, "deleted_at") _daemonGcTagRunner.ID = field.NewInt64(tableName, "id") _daemonGcTagRunner.RuleID = field.NewInt64(tableName, "rule_id") _daemonGcTagRunner.Message = field.NewBytes(tableName, "message") @@ -59,9 +59,9 @@ type daemonGcTagRunner struct { daemonGcTagRunnerDo daemonGcTagRunnerDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 RuleID field.Int64 Message field.Bytes @@ -88,9 +88,9 @@ func (d daemonGcTagRunner) As(alias string) *daemonGcTagRunner { func (d *daemonGcTagRunner) updateTableName(table string) *daemonGcTagRunner { d.ALL = field.NewAsterisk(table) - d.CreatedAt = field.NewTime(table, "created_at") - d.UpdatedAt = field.NewTime(table, "updated_at") - d.DeletedAt = field.NewUint(table, "deleted_at") + d.CreatedAt = field.NewInt64(table, "created_at") + d.UpdatedAt = field.NewInt64(table, "updated_at") + d.DeletedAt = field.NewUint64(table, "deleted_at") d.ID = field.NewInt64(table, "id") d.RuleID = field.NewInt64(table, "rule_id") d.Message = field.NewBytes(table, "message") diff --git a/pkg/dal/query/lockers.gen.go b/pkg/dal/query/lockers.gen.go index e84ebc65..23a7557a 100644 --- a/pkg/dal/query/lockers.gen.go +++ b/pkg/dal/query/lockers.gen.go @@ -27,9 +27,9 @@ func newLocker(db *gorm.DB, opts ...gen.DOOption) locker { tableName := _locker.lockerDo.TableName() _locker.ALL = field.NewAsterisk(tableName) - _locker.CreatedAt = field.NewTime(tableName, "created_at") - _locker.UpdatedAt = field.NewTime(tableName, "updated_at") - _locker.DeletedAt = field.NewUint(tableName, "deleted_at") + _locker.CreatedAt = field.NewInt64(tableName, "created_at") + _locker.UpdatedAt = field.NewInt64(tableName, "updated_at") + _locker.DeletedAt = field.NewUint64(tableName, "deleted_at") _locker.ID = field.NewInt64(tableName, "id") _locker.Name = field.NewString(tableName, "name") @@ -42,9 +42,9 @@ type locker struct { lockerDo lockerDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 Name field.String @@ -63,9 +63,9 @@ func (l locker) As(alias string) *locker { func (l *locker) updateTableName(table string) *locker { l.ALL = field.NewAsterisk(table) - l.CreatedAt = field.NewTime(table, "created_at") - l.UpdatedAt = field.NewTime(table, "updated_at") - l.DeletedAt = field.NewUint(table, "deleted_at") + l.CreatedAt = field.NewInt64(table, "created_at") + l.UpdatedAt = field.NewInt64(table, "updated_at") + l.DeletedAt = field.NewUint64(table, "deleted_at") l.ID = field.NewInt64(table, "id") l.Name = field.NewString(table, "name") diff --git a/pkg/dal/query/namespace_members.gen.go b/pkg/dal/query/namespace_members.gen.go index 7fc55d47..99ba1768 100644 --- a/pkg/dal/query/namespace_members.gen.go +++ b/pkg/dal/query/namespace_members.gen.go @@ -27,9 +27,9 @@ func newNamespaceMember(db *gorm.DB, opts ...gen.DOOption) namespaceMember { tableName := _namespaceMember.namespaceMemberDo.TableName() _namespaceMember.ALL = field.NewAsterisk(tableName) - _namespaceMember.CreatedAt = field.NewTime(tableName, "created_at") - _namespaceMember.UpdatedAt = field.NewTime(tableName, "updated_at") - _namespaceMember.DeletedAt = field.NewUint(tableName, "deleted_at") + _namespaceMember.CreatedAt = field.NewInt64(tableName, "created_at") + _namespaceMember.UpdatedAt = field.NewInt64(tableName, "updated_at") + _namespaceMember.DeletedAt = field.NewUint64(tableName, "deleted_at") _namespaceMember.ID = field.NewInt64(tableName, "id") _namespaceMember.UserID = field.NewInt64(tableName, "user_id") _namespaceMember.NamespaceID = field.NewInt64(tableName, "namespace_id") @@ -55,9 +55,9 @@ type namespaceMember struct { namespaceMemberDo namespaceMemberDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 UserID field.Int64 NamespaceID field.Int64 @@ -81,9 +81,9 @@ func (n namespaceMember) As(alias string) *namespaceMember { func (n *namespaceMember) updateTableName(table string) *namespaceMember { n.ALL = field.NewAsterisk(table) - n.CreatedAt = field.NewTime(table, "created_at") - n.UpdatedAt = field.NewTime(table, "updated_at") - n.DeletedAt = field.NewUint(table, "deleted_at") + n.CreatedAt = field.NewInt64(table, "created_at") + n.UpdatedAt = field.NewInt64(table, "updated_at") + n.DeletedAt = field.NewUint64(table, "deleted_at") n.ID = field.NewInt64(table, "id") n.UserID = field.NewInt64(table, "user_id") n.NamespaceID = field.NewInt64(table, "namespace_id") diff --git a/pkg/dal/query/namespaces.gen.go b/pkg/dal/query/namespaces.gen.go index 2e89f602..2d5e6083 100644 --- a/pkg/dal/query/namespaces.gen.go +++ b/pkg/dal/query/namespaces.gen.go @@ -27,9 +27,9 @@ func newNamespace(db *gorm.DB, opts ...gen.DOOption) namespace { tableName := _namespace.namespaceDo.TableName() _namespace.ALL = field.NewAsterisk(tableName) - _namespace.CreatedAt = field.NewTime(tableName, "created_at") - _namespace.UpdatedAt = field.NewTime(tableName, "updated_at") - _namespace.DeletedAt = field.NewUint(tableName, "deleted_at") + _namespace.CreatedAt = field.NewInt64(tableName, "created_at") + _namespace.UpdatedAt = field.NewInt64(tableName, "updated_at") + _namespace.DeletedAt = field.NewUint64(tableName, "deleted_at") _namespace.ID = field.NewInt64(tableName, "id") _namespace.Name = field.NewString(tableName, "name") _namespace.Description = field.NewString(tableName, "description") @@ -50,9 +50,9 @@ type namespace struct { namespaceDo namespaceDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 Name field.String Description field.String @@ -79,9 +79,9 @@ func (n namespace) As(alias string) *namespace { func (n *namespace) updateTableName(table string) *namespace { n.ALL = field.NewAsterisk(table) - n.CreatedAt = field.NewTime(table, "created_at") - n.UpdatedAt = field.NewTime(table, "updated_at") - n.DeletedAt = field.NewUint(table, "deleted_at") + n.CreatedAt = field.NewInt64(table, "created_at") + n.UpdatedAt = field.NewInt64(table, "updated_at") + n.DeletedAt = field.NewUint64(table, "deleted_at") n.ID = field.NewInt64(table, "id") n.Name = field.NewString(table, "name") n.Description = field.NewString(table, "description") diff --git a/pkg/dal/query/repositories.gen.go b/pkg/dal/query/repositories.gen.go index 74b7a43b..15afad2c 100644 --- a/pkg/dal/query/repositories.gen.go +++ b/pkg/dal/query/repositories.gen.go @@ -27,9 +27,9 @@ func newRepository(db *gorm.DB, opts ...gen.DOOption) repository { tableName := _repository.repositoryDo.TableName() _repository.ALL = field.NewAsterisk(tableName) - _repository.CreatedAt = field.NewTime(tableName, "created_at") - _repository.UpdatedAt = field.NewTime(tableName, "updated_at") - _repository.DeletedAt = field.NewUint(tableName, "deleted_at") + _repository.CreatedAt = field.NewInt64(tableName, "created_at") + _repository.UpdatedAt = field.NewInt64(tableName, "updated_at") + _repository.DeletedAt = field.NewUint64(tableName, "deleted_at") _repository.ID = field.NewInt64(tableName, "id") _repository.NamespaceID = field.NewInt64(tableName, "namespace_id") _repository.Name = field.NewString(tableName, "name") @@ -82,9 +82,9 @@ type repository struct { repositoryDo repositoryDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 NamespaceID field.Int64 Name field.String @@ -114,9 +114,9 @@ func (r repository) As(alias string) *repository { func (r *repository) updateTableName(table string) *repository { r.ALL = field.NewAsterisk(table) - r.CreatedAt = field.NewTime(table, "created_at") - r.UpdatedAt = field.NewTime(table, "updated_at") - r.DeletedAt = field.NewUint(table, "deleted_at") + r.CreatedAt = field.NewInt64(table, "created_at") + r.UpdatedAt = field.NewInt64(table, "updated_at") + r.DeletedAt = field.NewUint64(table, "deleted_at") r.ID = field.NewInt64(table, "id") r.NamespaceID = field.NewInt64(table, "namespace_id") r.Name = field.NewString(table, "name") diff --git a/pkg/dal/query/settings.gen.go b/pkg/dal/query/settings.gen.go index dbd13105..cab68810 100644 --- a/pkg/dal/query/settings.gen.go +++ b/pkg/dal/query/settings.gen.go @@ -27,9 +27,9 @@ func newSetting(db *gorm.DB, opts ...gen.DOOption) setting { tableName := _setting.settingDo.TableName() _setting.ALL = field.NewAsterisk(tableName) - _setting.CreatedAt = field.NewTime(tableName, "created_at") - _setting.UpdatedAt = field.NewTime(tableName, "updated_at") - _setting.DeletedAt = field.NewUint(tableName, "deleted_at") + _setting.CreatedAt = field.NewInt64(tableName, "created_at") + _setting.UpdatedAt = field.NewInt64(tableName, "updated_at") + _setting.DeletedAt = field.NewUint64(tableName, "deleted_at") _setting.ID = field.NewInt64(tableName, "id") _setting.Key = field.NewString(tableName, "key") _setting.Val = field.NewBytes(tableName, "val") @@ -43,9 +43,9 @@ type setting struct { settingDo settingDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 Key field.String Val field.Bytes @@ -65,9 +65,9 @@ func (s setting) As(alias string) *setting { func (s *setting) updateTableName(table string) *setting { s.ALL = field.NewAsterisk(table) - s.CreatedAt = field.NewTime(table, "created_at") - s.UpdatedAt = field.NewTime(table, "updated_at") - s.DeletedAt = field.NewUint(table, "deleted_at") + s.CreatedAt = field.NewInt64(table, "created_at") + s.UpdatedAt = field.NewInt64(table, "updated_at") + s.DeletedAt = field.NewUint64(table, "deleted_at") s.ID = field.NewInt64(table, "id") s.Key = field.NewString(table, "key") s.Val = field.NewBytes(table, "val") diff --git a/pkg/dal/query/tags.gen.go b/pkg/dal/query/tags.gen.go index e43ac6f9..1d6999dc 100644 --- a/pkg/dal/query/tags.gen.go +++ b/pkg/dal/query/tags.gen.go @@ -27,9 +27,9 @@ func newTag(db *gorm.DB, opts ...gen.DOOption) tag { tableName := _tag.tagDo.TableName() _tag.ALL = field.NewAsterisk(tableName) - _tag.CreatedAt = field.NewTime(tableName, "created_at") - _tag.UpdatedAt = field.NewTime(tableName, "updated_at") - _tag.DeletedAt = field.NewUint(tableName, "deleted_at") + _tag.CreatedAt = field.NewInt64(tableName, "created_at") + _tag.UpdatedAt = field.NewInt64(tableName, "updated_at") + _tag.DeletedAt = field.NewUint64(tableName, "deleted_at") _tag.ID = field.NewInt64(tableName, "id") _tag.RepositoryID = field.NewInt64(tableName, "repository_id") _tag.ArtifactID = field.NewInt64(tableName, "artifact_id") @@ -151,9 +151,9 @@ type tag struct { tagDo tagDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 RepositoryID field.Int64 ArtifactID field.Int64 @@ -180,9 +180,9 @@ func (t tag) As(alias string) *tag { func (t *tag) updateTableName(table string) *tag { t.ALL = field.NewAsterisk(table) - t.CreatedAt = field.NewTime(table, "created_at") - t.UpdatedAt = field.NewTime(table, "updated_at") - t.DeletedAt = field.NewUint(table, "deleted_at") + t.CreatedAt = field.NewInt64(table, "created_at") + t.UpdatedAt = field.NewInt64(table, "updated_at") + t.DeletedAt = field.NewUint64(table, "deleted_at") t.ID = field.NewInt64(table, "id") t.RepositoryID = field.NewInt64(table, "repository_id") t.ArtifactID = field.NewInt64(table, "artifact_id") diff --git a/pkg/dal/query/user_3rdparty.gen.go b/pkg/dal/query/user_3rdparty.gen.go index c4448739..6a8e1a62 100644 --- a/pkg/dal/query/user_3rdparty.gen.go +++ b/pkg/dal/query/user_3rdparty.gen.go @@ -27,9 +27,9 @@ func newUser3rdParty(db *gorm.DB, opts ...gen.DOOption) user3rdParty { tableName := _user3rdParty.user3rdPartyDo.TableName() _user3rdParty.ALL = field.NewAsterisk(tableName) - _user3rdParty.CreatedAt = field.NewTime(tableName, "created_at") - _user3rdParty.UpdatedAt = field.NewTime(tableName, "updated_at") - _user3rdParty.DeletedAt = field.NewUint(tableName, "deleted_at") + _user3rdParty.CreatedAt = field.NewInt64(tableName, "created_at") + _user3rdParty.UpdatedAt = field.NewInt64(tableName, "updated_at") + _user3rdParty.DeletedAt = field.NewUint64(tableName, "deleted_at") _user3rdParty.ID = field.NewInt64(tableName, "id") _user3rdParty.UserID = field.NewInt64(tableName, "user_id") _user3rdParty.Provider = field.NewField(tableName, "provider") @@ -54,9 +54,9 @@ type user3rdParty struct { user3rdPartyDo user3rdPartyDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 UserID field.Int64 Provider field.Field @@ -83,9 +83,9 @@ func (u user3rdParty) As(alias string) *user3rdParty { func (u *user3rdParty) updateTableName(table string) *user3rdParty { u.ALL = field.NewAsterisk(table) - u.CreatedAt = field.NewTime(table, "created_at") - u.UpdatedAt = field.NewTime(table, "updated_at") - u.DeletedAt = field.NewUint(table, "deleted_at") + u.CreatedAt = field.NewInt64(table, "created_at") + u.UpdatedAt = field.NewInt64(table, "updated_at") + u.DeletedAt = field.NewUint64(table, "deleted_at") u.ID = field.NewInt64(table, "id") u.UserID = field.NewInt64(table, "user_id") u.Provider = field.NewField(table, "provider") diff --git a/pkg/dal/query/user_recover_codes.gen.go b/pkg/dal/query/user_recover_codes.gen.go index fe9b23bb..b5988bd6 100644 --- a/pkg/dal/query/user_recover_codes.gen.go +++ b/pkg/dal/query/user_recover_codes.gen.go @@ -27,9 +27,9 @@ func newUserRecoverCode(db *gorm.DB, opts ...gen.DOOption) userRecoverCode { tableName := _userRecoverCode.userRecoverCodeDo.TableName() _userRecoverCode.ALL = field.NewAsterisk(tableName) - _userRecoverCode.CreatedAt = field.NewTime(tableName, "created_at") - _userRecoverCode.UpdatedAt = field.NewTime(tableName, "updated_at") - _userRecoverCode.DeletedAt = field.NewUint(tableName, "deleted_at") + _userRecoverCode.CreatedAt = field.NewInt64(tableName, "created_at") + _userRecoverCode.UpdatedAt = field.NewInt64(tableName, "updated_at") + _userRecoverCode.DeletedAt = field.NewUint64(tableName, "deleted_at") _userRecoverCode.ID = field.NewInt64(tableName, "id") _userRecoverCode.UserID = field.NewInt64(tableName, "user_id") _userRecoverCode.Code = field.NewString(tableName, "code") @@ -48,9 +48,9 @@ type userRecoverCode struct { userRecoverCodeDo userRecoverCodeDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 UserID field.Int64 Code field.String @@ -71,9 +71,9 @@ func (u userRecoverCode) As(alias string) *userRecoverCode { func (u *userRecoverCode) updateTableName(table string) *userRecoverCode { u.ALL = field.NewAsterisk(table) - u.CreatedAt = field.NewTime(table, "created_at") - u.UpdatedAt = field.NewTime(table, "updated_at") - u.DeletedAt = field.NewUint(table, "deleted_at") + u.CreatedAt = field.NewInt64(table, "created_at") + u.UpdatedAt = field.NewInt64(table, "updated_at") + u.DeletedAt = field.NewUint64(table, "deleted_at") u.ID = field.NewInt64(table, "id") u.UserID = field.NewInt64(table, "user_id") u.Code = field.NewString(table, "code") diff --git a/pkg/dal/query/users.gen.go b/pkg/dal/query/users.gen.go index c68ca35e..d6f9615c 100644 --- a/pkg/dal/query/users.gen.go +++ b/pkg/dal/query/users.gen.go @@ -27,9 +27,9 @@ func newUser(db *gorm.DB, opts ...gen.DOOption) user { tableName := _user.userDo.TableName() _user.ALL = field.NewAsterisk(tableName) - _user.CreatedAt = field.NewTime(tableName, "created_at") - _user.UpdatedAt = field.NewTime(tableName, "updated_at") - _user.DeletedAt = field.NewUint(tableName, "deleted_at") + _user.CreatedAt = field.NewInt64(tableName, "created_at") + _user.UpdatedAt = field.NewInt64(tableName, "updated_at") + _user.DeletedAt = field.NewUint64(tableName, "deleted_at") _user.ID = field.NewInt64(tableName, "id") _user.Username = field.NewString(tableName, "username") _user.Password = field.NewString(tableName, "password") @@ -49,9 +49,9 @@ type user struct { userDo userDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 Username field.String Password field.String @@ -77,9 +77,9 @@ func (u user) As(alias string) *user { func (u *user) updateTableName(table string) *user { u.ALL = field.NewAsterisk(table) - u.CreatedAt = field.NewTime(table, "created_at") - u.UpdatedAt = field.NewTime(table, "updated_at") - u.DeletedAt = field.NewUint(table, "deleted_at") + u.CreatedAt = field.NewInt64(table, "created_at") + u.UpdatedAt = field.NewInt64(table, "updated_at") + u.DeletedAt = field.NewUint64(table, "deleted_at") u.ID = field.NewInt64(table, "id") u.Username = field.NewString(table, "username") u.Password = field.NewString(table, "password") diff --git a/pkg/dal/query/webhook_logs.gen.go b/pkg/dal/query/webhook_logs.gen.go index f4dfa83f..20693996 100644 --- a/pkg/dal/query/webhook_logs.gen.go +++ b/pkg/dal/query/webhook_logs.gen.go @@ -27,9 +27,9 @@ func newWebhookLog(db *gorm.DB, opts ...gen.DOOption) webhookLog { tableName := _webhookLog.webhookLogDo.TableName() _webhookLog.ALL = field.NewAsterisk(tableName) - _webhookLog.CreatedAt = field.NewTime(tableName, "created_at") - _webhookLog.UpdatedAt = field.NewTime(tableName, "updated_at") - _webhookLog.DeletedAt = field.NewUint(tableName, "deleted_at") + _webhookLog.CreatedAt = field.NewInt64(tableName, "created_at") + _webhookLog.UpdatedAt = field.NewInt64(tableName, "updated_at") + _webhookLog.DeletedAt = field.NewUint64(tableName, "deleted_at") _webhookLog.ID = field.NewInt64(tableName, "id") _webhookLog.WebhookID = field.NewInt64(tableName, "webhook_id") _webhookLog.Event = field.NewField(tableName, "event") @@ -54,9 +54,9 @@ type webhookLog struct { webhookLogDo webhookLogDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 WebhookID field.Int64 Event field.Field @@ -83,9 +83,9 @@ func (w webhookLog) As(alias string) *webhookLog { func (w *webhookLog) updateTableName(table string) *webhookLog { w.ALL = field.NewAsterisk(table) - w.CreatedAt = field.NewTime(table, "created_at") - w.UpdatedAt = field.NewTime(table, "updated_at") - w.DeletedAt = field.NewUint(table, "deleted_at") + w.CreatedAt = field.NewInt64(table, "created_at") + w.UpdatedAt = field.NewInt64(table, "updated_at") + w.DeletedAt = field.NewUint64(table, "deleted_at") w.ID = field.NewInt64(table, "id") w.WebhookID = field.NewInt64(table, "webhook_id") w.Event = field.NewField(table, "event") diff --git a/pkg/dal/query/webhooks.gen.go b/pkg/dal/query/webhooks.gen.go index 4cf778b4..24782710 100644 --- a/pkg/dal/query/webhooks.gen.go +++ b/pkg/dal/query/webhooks.gen.go @@ -27,9 +27,9 @@ func newWebhook(db *gorm.DB, opts ...gen.DOOption) webhook { tableName := _webhook.webhookDo.TableName() _webhook.ALL = field.NewAsterisk(tableName) - _webhook.CreatedAt = field.NewTime(tableName, "created_at") - _webhook.UpdatedAt = field.NewTime(tableName, "updated_at") - _webhook.DeletedAt = field.NewUint(tableName, "deleted_at") + _webhook.CreatedAt = field.NewInt64(tableName, "created_at") + _webhook.UpdatedAt = field.NewInt64(tableName, "updated_at") + _webhook.DeletedAt = field.NewUint64(tableName, "deleted_at") _webhook.ID = field.NewInt64(tableName, "id") _webhook.NamespaceID = field.NewInt64(tableName, "namespace_id") _webhook.Url = field.NewString(tableName, "url") @@ -53,9 +53,9 @@ type webhook struct { webhookDo webhookDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 NamespaceID field.Int64 Url field.String @@ -85,9 +85,9 @@ func (w webhook) As(alias string) *webhook { func (w *webhook) updateTableName(table string) *webhook { w.ALL = field.NewAsterisk(table) - w.CreatedAt = field.NewTime(table, "created_at") - w.UpdatedAt = field.NewTime(table, "updated_at") - w.DeletedAt = field.NewUint(table, "deleted_at") + w.CreatedAt = field.NewInt64(table, "created_at") + w.UpdatedAt = field.NewInt64(table, "updated_at") + w.DeletedAt = field.NewUint64(table, "deleted_at") w.ID = field.NewInt64(table, "id") w.NamespaceID = field.NewInt64(table, "namespace_id") w.Url = field.NewString(table, "url") diff --git a/pkg/dal/query/work_queues.gen.go b/pkg/dal/query/work_queues.gen.go index 088ce46e..7ba9fbb2 100644 --- a/pkg/dal/query/work_queues.gen.go +++ b/pkg/dal/query/work_queues.gen.go @@ -27,9 +27,9 @@ func newWorkQueue(db *gorm.DB, opts ...gen.DOOption) workQueue { tableName := _workQueue.workQueueDo.TableName() _workQueue.ALL = field.NewAsterisk(tableName) - _workQueue.CreatedAt = field.NewTime(tableName, "created_at") - _workQueue.UpdatedAt = field.NewTime(tableName, "updated_at") - _workQueue.DeletedAt = field.NewUint(tableName, "deleted_at") + _workQueue.CreatedAt = field.NewInt64(tableName, "created_at") + _workQueue.UpdatedAt = field.NewInt64(tableName, "updated_at") + _workQueue.DeletedAt = field.NewUint64(tableName, "deleted_at") _workQueue.ID = field.NewInt64(tableName, "id") _workQueue.Topic = field.NewString(tableName, "topic") _workQueue.Payload = field.NewBytes(tableName, "payload") @@ -46,9 +46,9 @@ type workQueue struct { workQueueDo workQueueDo ALL field.Asterisk - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Uint + CreatedAt field.Int64 + UpdatedAt field.Int64 + DeletedAt field.Uint64 ID field.Int64 Topic field.String Payload field.Bytes @@ -71,9 +71,9 @@ func (w workQueue) As(alias string) *workQueue { func (w *workQueue) updateTableName(table string) *workQueue { w.ALL = field.NewAsterisk(table) - w.CreatedAt = field.NewTime(table, "created_at") - w.UpdatedAt = field.NewTime(table, "updated_at") - w.DeletedAt = field.NewUint(table, "deleted_at") + w.CreatedAt = field.NewInt64(table, "created_at") + w.UpdatedAt = field.NewInt64(table, "updated_at") + w.DeletedAt = field.NewUint64(table, "deleted_at") w.ID = field.NewInt64(table, "id") w.Topic = field.NewString(table, "topic") w.Payload = field.NewBytes(table, "payload") diff --git a/pkg/handlers/artifacts/artifacts_get.go b/pkg/handlers/artifacts/artifacts_get.go index 5c861768..856a95c8 100644 --- a/pkg/handlers/artifacts/artifacts_get.go +++ b/pkg/handlers/artifacts/artifacts_get.go @@ -16,6 +16,7 @@ package artifact import ( "errors" + "time" "github.com/labstack/echo/v4" "github.com/rs/zerolog/log" @@ -69,7 +70,7 @@ func (h *handler) GetArtifact(c echo.Context) error { PullTimes: artifactObj.PullTimes, LastPull: artifactObj.LastPull.Time.Format(consts.DefaultTimePattern), PushedAt: artifactObj.PushedAt.Format(consts.DefaultTimePattern), - CreatedAt: artifactObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: artifactObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*artifactObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*artifactObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } diff --git a/pkg/handlers/artifacts/artifacts_list.go b/pkg/handlers/artifacts/artifacts_list.go index 615fa334..b73bbe48 100644 --- a/pkg/handlers/artifacts/artifacts_list.go +++ b/pkg/handlers/artifacts/artifacts_list.go @@ -16,6 +16,7 @@ package artifact import ( "net/http" + "time" "github.com/labstack/echo/v4" "github.com/rs/zerolog/log" @@ -38,20 +39,20 @@ func (h *handler) ListArtifact(c echo.Context) error { } artifactService := h.artifactServiceFactory.New() - artifacts, err := artifactService.ListArtifact(ctx, req) + artifactObjs, err := artifactService.ListArtifact(ctx, req) if err != nil { log.Error().Err(err).Msg("List artifact from db failed") return xerrors.NewHTTPError(c, xerrors.HTTPErrCodeInternalError, err.Error()) } - var resp = make([]any, 0, len(artifacts)) - for _, artifact := range artifacts { + var resp = make([]any, 0, len(artifactObjs)) + for _, artifactObj := range artifactObjs { resp = append(resp, types.ArtifactItem{ - ID: artifact.ID, - Digest: artifact.Digest, - Size: artifact.Size, - CreatedAt: artifact.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: artifact.UpdatedAt.Format(consts.DefaultTimePattern), + ID: artifactObj.ID, + Digest: artifactObj.Digest, + Size: artifactObj.Size, + CreatedAt: time.Unix(0, int64(time.Millisecond)*artifactObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*artifactObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } total, err := artifactService.CountArtifact(ctx, req) diff --git a/pkg/handlers/builders/builders_runner_get.go b/pkg/handlers/builders/builders_runner_get.go index 5fb49ebd..4eeaa9d0 100644 --- a/pkg/handlers/builders/builders_runner_get.go +++ b/pkg/handlers/builders/builders_runner_get.go @@ -102,7 +102,7 @@ func (h *handler) GetRunner(c echo.Context) error { RawDuration: runnerObj.Duration, Duration: duration, - CreatedAt: runnerObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: runnerObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*runnerObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*runnerObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } diff --git a/pkg/handlers/builders/builders_runners_list.go b/pkg/handlers/builders/builders_runners_list.go index b95d1878..5f4ca005 100644 --- a/pkg/handlers/builders/builders_runners_list.go +++ b/pkg/handlers/builders/builders_runners_list.go @@ -100,8 +100,8 @@ func (h *handler) ListRunners(c echo.Context) error { RawDuration: runnerObj.Duration, Duration: duration, - CreatedAt: runnerObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: runnerObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*runnerObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*runnerObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } return c.JSON(http.StatusOK, types.CommonList{Total: total, Items: resp}) diff --git a/pkg/handlers/coderepos/coderepos_branches.go b/pkg/handlers/coderepos/coderepos_branches.go index 97f7b8f6..8acd45a0 100644 --- a/pkg/handlers/coderepos/coderepos_branches.go +++ b/pkg/handlers/coderepos/coderepos_branches.go @@ -17,6 +17,7 @@ package coderepos import ( "fmt" "net/http" + "time" "github.com/labstack/echo/v4" "github.com/rs/zerolog/log" @@ -59,8 +60,8 @@ func (h *handler) ListBranches(c echo.Context) error { resp = append(resp, types.CodeRepositoryBranchItem{ ID: branchObj.ID, Name: branchObj.Name, - CreatedAt: branchObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: branchObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*branchObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*branchObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } diff --git a/pkg/handlers/coderepos/coderepos_get.go b/pkg/handlers/coderepos/coderepos_get.go index 26fb27c0..f25f4b5b 100644 --- a/pkg/handlers/coderepos/coderepos_get.go +++ b/pkg/handlers/coderepos/coderepos_get.go @@ -18,6 +18,7 @@ import ( "errors" "fmt" "net/http" + "time" "github.com/labstack/echo/v4" "github.com/rs/zerolog/log" @@ -75,7 +76,7 @@ func (h *handler) Get(c echo.Context) error { CloneUrl: codeRepositoryObj.CloneUrl, SshUrl: codeRepositoryObj.SshUrl, OciRepoCount: codeRepositoryObj.OciRepoCount, - CreatedAt: codeRepositoryObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: codeRepositoryObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*codeRepositoryObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*codeRepositoryObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } diff --git a/pkg/handlers/coderepos/coderepos_list.go b/pkg/handlers/coderepos/coderepos_list.go index 0964a2bc..641ed165 100644 --- a/pkg/handlers/coderepos/coderepos_list.go +++ b/pkg/handlers/coderepos/coderepos_list.go @@ -16,6 +16,7 @@ package coderepos import ( "net/http" + "time" "github.com/labstack/echo/v4" "github.com/rs/zerolog/log" @@ -84,8 +85,8 @@ func (h *handler) List(c echo.Context) error { CloneUrl: codeRepositoryObj.CloneUrl, SshUrl: codeRepositoryObj.SshUrl, OciRepoCount: codeRepositoryObj.OciRepoCount, - CreatedAt: codeRepositoryObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: codeRepositoryObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*codeRepositoryObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*codeRepositoryObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } diff --git a/pkg/handlers/coderepos/coderepos_owners_list.go b/pkg/handlers/coderepos/coderepos_owners_list.go index aef3b6da..95cbbbd6 100644 --- a/pkg/handlers/coderepos/coderepos_owners_list.go +++ b/pkg/handlers/coderepos/coderepos_owners_list.go @@ -16,6 +16,7 @@ package coderepos import ( "net/http" + "time" "github.com/labstack/echo/v4" "github.com/rs/zerolog/log" @@ -73,8 +74,8 @@ func (h *handler) ListOwners(c echo.Context) error { OwnerID: codeRepositoryOwnerObj.OwnerID, Owner: codeRepositoryOwnerObj.Owner, IsOrg: codeRepositoryOwnerObj.IsOrg, - CreatedAt: codeRepositoryOwnerObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: codeRepositoryOwnerObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*codeRepositoryOwnerObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*codeRepositoryOwnerObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } diff --git a/pkg/handlers/coderepos/coderepos_user3rdparty.go b/pkg/handlers/coderepos/coderepos_user3rdparty.go index 90f76461..fdd3c444 100644 --- a/pkg/handlers/coderepos/coderepos_user3rdparty.go +++ b/pkg/handlers/coderepos/coderepos_user3rdparty.go @@ -17,6 +17,7 @@ package coderepos import ( "errors" "net/http" + "time" "github.com/labstack/echo/v4" "github.com/rs/zerolog/log" @@ -80,7 +81,7 @@ func (h *handler) User3rdParty(c echo.Context) error { CrLastUpdateStatus: user3rdPartyObj.CrLastUpdateStatus, CrLastUpdateMessage: user3rdPartyObj.CrLastUpdateMessage, - CreatedAt: user3rdPartyObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: user3rdPartyObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*user3rdPartyObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*user3rdPartyObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } diff --git a/pkg/handlers/daemons/daemons_gc_artifact.go b/pkg/handlers/daemons/daemons_gc_artifact.go index dd0ee871..f02da6ca 100644 --- a/pkg/handlers/daemons/daemons_gc_artifact.go +++ b/pkg/handlers/daemons/daemons_gc_artifact.go @@ -160,8 +160,8 @@ func (h *handler) GetGcArtifactRule(c echo.Context) error { CronEnabled: ruleObj.CronEnabled, CronRule: ruleObj.CronRule, CronNextTrigger: ptr.Of(ptr.To(ruleObj.CronNextTrigger).Format(consts.DefaultTimePattern)), - CreatedAt: ruleObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: ruleObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*ruleObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*ruleObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } @@ -231,8 +231,8 @@ func (h *handler) GetGcArtifactLatestRunner(c echo.Context) error { Duration: duration, StartedAt: ptr.Of(startedAt), EndedAt: ptr.Of(endedAt), - CreatedAt: runnerObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: runnerObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*runnerObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*runnerObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } @@ -370,8 +370,8 @@ func (h *handler) ListGcArtifactRunners(c echo.Context) error { Duration: duration, StartedAt: ptr.Of(startedAt), EndedAt: ptr.Of(endedAt), - CreatedAt: runnerObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: runnerObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*runnerObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*runnerObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } return c.JSON(http.StatusOK, types.CommonList{Total: total, Items: resp}) @@ -435,8 +435,8 @@ func (h *handler) GetGcArtifactRunner(c echo.Context) error { Duration: duration, StartedAt: ptr.Of(startedAt), EndedAt: ptr.Of(endedAt), - CreatedAt: runnerObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: runnerObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*runnerObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*runnerObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } @@ -480,8 +480,8 @@ func (h *handler) ListGcArtifactRecords(c echo.Context) error { Digest: recordObj.Digest, Status: recordObj.Status, Message: string(recordObj.Message), - CreatedAt: recordObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: recordObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*recordObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*recordObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } return c.JSON(http.StatusOK, types.CommonList{Total: total, Items: resp}) @@ -543,7 +543,7 @@ func (h *handler) GetGcArtifactRecord(c echo.Context) error { Digest: recordObj.Digest, Status: recordObj.Status, Message: string(recordObj.Message), - CreatedAt: recordObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: recordObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*recordObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*recordObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } diff --git a/pkg/handlers/daemons/daemons_gc_blob.go b/pkg/handlers/daemons/daemons_gc_blob.go index 061667fa..62bf506f 100644 --- a/pkg/handlers/daemons/daemons_gc_blob.go +++ b/pkg/handlers/daemons/daemons_gc_blob.go @@ -153,8 +153,8 @@ func (h *handler) GetGcBlobRule(c echo.Context) error { CronEnabled: ruleObj.CronEnabled, CronRule: ruleObj.CronRule, CronNextTrigger: ptr.Of(ptr.To(ruleObj.CronNextTrigger).Format(consts.DefaultTimePattern)), - CreatedAt: ruleObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: ruleObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*ruleObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*ruleObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } @@ -221,8 +221,8 @@ func (h *handler) GetGcBlobLatestRunner(c echo.Context) error { Duration: duration, StartedAt: ptr.Of(startedAt), EndedAt: ptr.Of(endedAt), - CreatedAt: ruleObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: ruleObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*ruleObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*ruleObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } @@ -354,8 +354,8 @@ func (h *handler) ListGcBlobRunners(c echo.Context) error { Duration: duration, StartedAt: ptr.Of(startedAt), EndedAt: ptr.Of(endedAt), - CreatedAt: runnerObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: runnerObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*runnerObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*runnerObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } return c.JSON(http.StatusOK, types.CommonList{Total: total, Items: resp}) @@ -415,8 +415,8 @@ func (h *handler) GetGcBlobRunner(c echo.Context) error { Duration: duration, StartedAt: ptr.Of(startedAt), EndedAt: ptr.Of(endedAt), - CreatedAt: runnerObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: runnerObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*runnerObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*runnerObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } @@ -460,8 +460,8 @@ func (h *handler) ListGcBlobRecords(c echo.Context) error { Digest: recordObj.Digest, Status: recordObj.Status, Message: string(recordObj.Message), - CreatedAt: recordObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: recordObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*recordObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*recordObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } return c.JSON(http.StatusOK, types.CommonList{Total: total, Items: resp}) @@ -519,7 +519,7 @@ func (h *handler) GetGcBlobRecord(c echo.Context) error { Digest: recordObj.Digest, Status: recordObj.Status, Message: string(recordObj.Message), - CreatedAt: recordObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: recordObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*recordObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*recordObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } diff --git a/pkg/handlers/daemons/daemons_gc_repository.go b/pkg/handlers/daemons/daemons_gc_repository.go index a7ad67d2..382901a8 100644 --- a/pkg/handlers/daemons/daemons_gc_repository.go +++ b/pkg/handlers/daemons/daemons_gc_repository.go @@ -160,8 +160,8 @@ func (h *handler) GetGcRepositoryRule(c echo.Context) error { CronEnabled: ruleObj.CronEnabled, CronRule: ruleObj.CronRule, CronNextTrigger: ptr.Of(ptr.To(ruleObj.CronNextTrigger).Format(consts.DefaultTimePattern)), - CreatedAt: ruleObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: ruleObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*ruleObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*ruleObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } @@ -231,8 +231,8 @@ func (h *handler) GetGcRepositoryLatestRunner(c echo.Context) error { Duration: duration, StartedAt: ptr.Of(startedAt), EndedAt: ptr.Of(endedAt), - CreatedAt: ruleObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: ruleObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*ruleObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*ruleObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } @@ -371,8 +371,8 @@ func (h *handler) ListGcRepositoryRunners(c echo.Context) error { Duration: duration, StartedAt: ptr.Of(startedAt), EndedAt: ptr.Of(endedAt), - CreatedAt: runnerObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: runnerObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*runnerObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*runnerObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } return c.JSON(http.StatusOK, types.CommonList{Total: total, Items: resp}) @@ -436,8 +436,8 @@ func (h *handler) GetGcRepositoryRunner(c echo.Context) error { Duration: duration, StartedAt: ptr.Of(startedAt), EndedAt: ptr.Of(endedAt), - CreatedAt: runnerObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: runnerObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*runnerObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*runnerObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } @@ -481,8 +481,8 @@ func (h *handler) ListGcRepositoryRecords(c echo.Context) error { Repository: recordObj.Repository, Status: recordObj.Status, Message: string(recordObj.Message), - CreatedAt: recordObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: recordObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*recordObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*recordObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } return c.JSON(http.StatusOK, types.CommonList{Total: total, Items: resp}) @@ -544,7 +544,7 @@ func (h *handler) GetGcRepositoryRecord(c echo.Context) error { Repository: recordObj.Repository, Status: recordObj.Status, Message: string(recordObj.Message), - CreatedAt: recordObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: recordObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*recordObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*recordObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } diff --git a/pkg/handlers/daemons/daemons_gc_tags.go b/pkg/handlers/daemons/daemons_gc_tags.go index 2afbb19d..be8cf9a5 100644 --- a/pkg/handlers/daemons/daemons_gc_tags.go +++ b/pkg/handlers/daemons/daemons_gc_tags.go @@ -170,8 +170,8 @@ func (h *handler) GetGcTagRule(c echo.Context) error { RetentionRuleType: ruleObj.RetentionRuleType, RetentionRuleAmount: ruleObj.RetentionRuleAmount, RetentionPattern: ruleObj.RetentionPattern, - CreatedAt: ruleObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: ruleObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*ruleObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*ruleObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } @@ -241,8 +241,8 @@ func (h *handler) GetGcTagLatestRunner(c echo.Context) error { Duration: duration, StartedAt: ptr.Of(startedAt), EndedAt: ptr.Of(endedAt), - CreatedAt: ruleObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: ruleObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*ruleObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*ruleObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } @@ -381,8 +381,8 @@ func (h *handler) ListGcTagRunners(c echo.Context) error { Duration: duration, StartedAt: ptr.Of(startedAt), EndedAt: ptr.Of(endedAt), - CreatedAt: runnerObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: runnerObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*runnerObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*runnerObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } return c.JSON(http.StatusOK, types.CommonList{Total: total, Items: resp}) @@ -446,8 +446,8 @@ func (h *handler) GetGcTagRunner(c echo.Context) error { Duration: duration, StartedAt: ptr.Of(startedAt), EndedAt: ptr.Of(endedAt), - CreatedAt: runnerObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: runnerObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*runnerObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*runnerObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } @@ -491,8 +491,8 @@ func (h *handler) ListGcTagRecords(c echo.Context) error { Tag: recordObj.Tag, Status: recordObj.Status, Message: string(recordObj.Message), - CreatedAt: recordObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: recordObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*recordObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*recordObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } return c.JSON(http.StatusOK, types.CommonList{Total: total, Items: resp}) @@ -554,7 +554,7 @@ func (h *handler) GetGcTagRecord(c echo.Context) error { Tag: recordObj.Tag, Status: recordObj.Status, Message: string(recordObj.Message), - CreatedAt: recordObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: recordObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*recordObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*recordObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } diff --git a/pkg/handlers/namespaces/namespaces_get.go b/pkg/handlers/namespaces/namespaces_get.go index e4e64951..c9c4f18a 100644 --- a/pkg/handlers/namespaces/namespaces_get.go +++ b/pkg/handlers/namespaces/namespaces_get.go @@ -17,6 +17,7 @@ package namespaces import ( "errors" "net/http" + "time" "github.com/labstack/echo/v4" "github.com/rs/zerolog/log" @@ -64,7 +65,7 @@ func (h *handler) GetNamespace(c echo.Context) error { } namespaceService := h.namespaceServiceFactory.New() - namespace, err := namespaceService.Get(ctx, req.ID) + namespaceObj, err := namespaceService.Get(ctx, req.ID) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { log.Error().Err(err).Msg("Get namespace from db failed") @@ -80,31 +81,31 @@ func (h *handler) GetNamespace(c echo.Context) error { } repositoryService := h.repositoryServiceFactory.New() - repositoryMapCount, err := repositoryService.CountByNamespace(ctx, []int64{namespace.ID}) + repositoryMapCount, err := repositoryService.CountByNamespace(ctx, []int64{namespaceObj.ID}) if err != nil { log.Error().Err(err).Msg("Count repository failed") return xerrors.NewHTTPError(c, xerrors.HTTPErrCodeInternalError, err.Error()) } tagService := h.tagServiceFactory.New() - tagMapCount, err := tagService.CountByNamespace(ctx, []int64{namespace.ID}) + tagMapCount, err := tagService.CountByNamespace(ctx, []int64{namespaceObj.ID}) if err != nil { log.Error().Err(err).Msg("Count tag failed") return xerrors.NewHTTPError(c, xerrors.HTTPErrCodeInternalError, err.Error()) } return c.JSON(http.StatusOK, types.NamespaceItem{ - ID: namespace.ID, - Name: namespace.Name, - Description: namespace.Description, - Visibility: namespace.Visibility, - Size: namespace.Size, - SizeLimit: namespace.SizeLimit, - RepositoryCount: repositoryMapCount[namespace.ID], - RepositoryLimit: namespace.RepositoryLimit, - TagCount: tagMapCount[namespace.ID], - TagLimit: namespace.TagLimit, - CreatedAt: namespace.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: namespace.UpdatedAt.Format(consts.DefaultTimePattern), + ID: namespaceObj.ID, + Name: namespaceObj.Name, + Description: namespaceObj.Description, + Visibility: namespaceObj.Visibility, + Size: namespaceObj.Size, + SizeLimit: namespaceObj.SizeLimit, + RepositoryCount: repositoryMapCount[namespaceObj.ID], + RepositoryLimit: namespaceObj.RepositoryLimit, + TagCount: tagMapCount[namespaceObj.ID], + TagLimit: namespaceObj.TagLimit, + CreatedAt: time.Unix(0, int64(time.Millisecond)*namespaceObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*namespaceObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } diff --git a/pkg/handlers/namespaces/namespaces_list.go b/pkg/handlers/namespaces/namespaces_list.go index b48bab6b..4aaa3e3b 100644 --- a/pkg/handlers/namespaces/namespaces_list.go +++ b/pkg/handlers/namespaces/namespaces_list.go @@ -16,6 +16,7 @@ package namespaces import ( "net/http" + "time" "github.com/labstack/echo/v4" "github.com/rs/zerolog/log" @@ -74,20 +75,20 @@ func (h *handler) ListNamespaces(c echo.Context) error { } var resp = make([]any, 0, len(namespaceObjs)) - for _, ns := range namespaceObjs { + for _, namespaceObj := range namespaceObjs { resp = append(resp, types.NamespaceItem{ - ID: ns.ID, - Name: ns.Name, - Description: ns.Description, - Visibility: ns.Visibility, - Size: ns.Size, - SizeLimit: ns.SizeLimit, - RepositoryLimit: ns.RepositoryLimit, - RepositoryCount: ns.RepositoryCount, - TagLimit: ns.TagLimit, - TagCount: ns.TagCount, - CreatedAt: ns.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: ns.UpdatedAt.Format(consts.DefaultTimePattern), + ID: namespaceObj.ID, + Name: namespaceObj.Name, + Description: namespaceObj.Description, + Visibility: namespaceObj.Visibility, + Size: namespaceObj.Size, + SizeLimit: namespaceObj.SizeLimit, + RepositoryLimit: namespaceObj.RepositoryLimit, + RepositoryCount: namespaceObj.RepositoryCount, + TagLimit: namespaceObj.TagLimit, + TagCount: namespaceObj.TagCount, + CreatedAt: time.Unix(0, int64(time.Millisecond)*namespaceObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*namespaceObj.UpdatedAt).UTC().Format(consts.DefaultTimePattern), }) } diff --git a/pkg/handlers/namespaces/namespaces_list_hot.go b/pkg/handlers/namespaces/namespaces_list_hot.go index c4aaec43..a7e4c779 100644 --- a/pkg/handlers/namespaces/namespaces_list_hot.go +++ b/pkg/handlers/namespaces/namespaces_list_hot.go @@ -16,6 +16,7 @@ package namespaces import ( "net/http" + "time" "github.com/labstack/echo/v4" "github.com/rs/zerolog/log" @@ -52,29 +53,29 @@ func (h *handler) HotNamespace(c echo.Context) error { } auditService := h.auditServiceFactory.New() - namespaces, err := auditService.HotNamespace(ctx, user.ID, consts.HotNamespace) // TODO: remove the namespace that user not have permission + namespaceObjs, err := auditService.HotNamespace(ctx, user.ID, consts.HotNamespace) // TODO: remove the namespace that user not have permission if err != nil { log.Error().Err(err).Msg("Get hot namespaces failed") return xerrors.NewHTTPError(c, xerrors.HTTPErrCodeInternalError, err.Error()) } - var resp = make([]any, 0, len(namespaces)) - for _, ns := range namespaces { + var resp = make([]any, 0, len(namespaceObjs)) + for _, namespaceObj := range namespaceObjs { resp = append(resp, types.NamespaceItem{ - ID: ns.ID, - Name: ns.Name, - Description: ns.Description, - Visibility: ns.Visibility, - Size: ns.Size, - SizeLimit: ns.SizeLimit, - RepositoryLimit: ns.RepositoryLimit, - RepositoryCount: ns.RepositoryCount, - TagLimit: ns.TagLimit, - TagCount: ns.TagCount, - CreatedAt: ns.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: ns.UpdatedAt.Format(consts.DefaultTimePattern), + ID: namespaceObj.ID, + Name: namespaceObj.Name, + Description: namespaceObj.Description, + Visibility: namespaceObj.Visibility, + Size: namespaceObj.Size, + SizeLimit: namespaceObj.SizeLimit, + RepositoryLimit: namespaceObj.RepositoryLimit, + RepositoryCount: namespaceObj.RepositoryCount, + TagLimit: namespaceObj.TagLimit, + TagCount: namespaceObj.TagCount, + CreatedAt: time.Unix(namespaceObj.CreatedAt, 0).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(namespaceObj.UpdatedAt, 0).UTC().Format(consts.DefaultTimePattern), }) } - return c.JSON(http.StatusOK, types.CommonList{Total: int64(len(namespaces)), Items: resp}) + return c.JSON(http.StatusOK, types.CommonList{Total: int64(len(namespaceObjs)), Items: resp}) } diff --git a/pkg/handlers/namespaces/namespaces_members_list.go b/pkg/handlers/namespaces/namespaces_members_list.go index 182a699c..0e4fc39b 100644 --- a/pkg/handlers/namespaces/namespaces_members_list.go +++ b/pkg/handlers/namespaces/namespaces_members_list.go @@ -17,6 +17,7 @@ package namespaces import ( "fmt" "net/http" + "time" "github.com/labstack/echo/v4" "github.com/rs/zerolog/log" @@ -39,21 +40,21 @@ func (h *handler) ListNamespaceMembers(c echo.Context) error { } namespaceMemberService := h.namespaceMemberServiceFactory.New() - namespaceRoleObjs, total, err := namespaceMemberService.ListNamespaceMembers(ctx, req.ID, req.Name, req.Pagination, req.Sortable) + namespaceMemberObjs, total, err := namespaceMemberService.ListNamespaceMembers(ctx, req.ID, req.Name, req.Pagination, req.Sortable) if err != nil { log.Error().Err(err).Msg("List namespace role failed") return xerrors.NewHTTPError(c, xerrors.HTTPErrCodeInternalError, fmt.Sprintf("List namespace role failed: %v", err)) } - var resp = make([]any, 0, len(namespaceRoleObjs)) - for _, namespaceRoleObj := range namespaceRoleObjs { + var resp = make([]any, 0, len(namespaceMemberObjs)) + for _, namespaceMemberObj := range namespaceMemberObjs { resp = append(resp, types.NamespaceRoleItem{ - ID: namespaceRoleObj.ID, - Username: namespaceRoleObj.User.Username, - UserID: namespaceRoleObj.User.ID, - Role: namespaceRoleObj.Role, - CreatedAt: namespaceRoleObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: namespaceRoleObj.UpdatedAt.Format(consts.DefaultTimePattern), + ID: namespaceMemberObj.ID, + Username: namespaceMemberObj.User.Username, + UserID: namespaceMemberObj.User.ID, + Role: namespaceMemberObj.Role, + CreatedAt: time.Unix(0, int64(time.Millisecond)*namespaceMemberObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*namespaceMemberObj.UpdatedAt).UTC().Format(consts.DefaultTimePattern), }) } diff --git a/pkg/handlers/namespaces/namespaces_members_self.go b/pkg/handlers/namespaces/namespaces_members_self.go index b374c273..c9c26d6e 100644 --- a/pkg/handlers/namespaces/namespaces_members_self.go +++ b/pkg/handlers/namespaces/namespaces_members_self.go @@ -18,6 +18,7 @@ import ( "errors" "fmt" "net/http" + "time" "github.com/labstack/echo/v4" "github.com/rs/zerolog/log" @@ -68,7 +69,7 @@ func (h *handler) GetNamespaceMemberSelf(c echo.Context) error { Username: user.Username, UserID: user.ID, Role: namespaceMemberObj.Role, - CreatedAt: namespaceMemberObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: namespaceMemberObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*namespaceMemberObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*namespaceMemberObj.UpdatedAt).UTC().Format(consts.DefaultTimePattern), }) } diff --git a/pkg/handlers/repositories/repositories_get.go b/pkg/handlers/repositories/repositories_get.go index fe3070f7..1a4e76ee 100644 --- a/pkg/handlers/repositories/repositories_get.go +++ b/pkg/handlers/repositories/repositories_get.go @@ -17,6 +17,7 @@ package repositories import ( "net/http" "strings" + "time" "github.com/labstack/echo/v4" "github.com/rs/zerolog/log" @@ -137,7 +138,7 @@ func (h *handler) GetRepository(c echo.Context) error { Size: ptr.Of(repositoryObj.Size), TagCount: repositoryObj.TagCount, Builder: builderItemObj, - CreatedAt: repositoryObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: repositoryObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*repositoryObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*repositoryObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } diff --git a/pkg/handlers/repositories/repositories_list.go b/pkg/handlers/repositories/repositories_list.go index abc40652..e98b7ae0 100644 --- a/pkg/handlers/repositories/repositories_list.go +++ b/pkg/handlers/repositories/repositories_list.go @@ -19,6 +19,7 @@ import ( "fmt" "net/http" "strings" + "time" "github.com/labstack/echo/v4" "github.com/rs/zerolog/log" @@ -86,14 +87,14 @@ func (h *handler) ListRepositories(c echo.Context) error { } repositoryService := h.repositoryServiceFactory.New() - repositories, total, err := repositoryService.ListRepositoryWithAuth(ctx, namespaceObj.ID, user.ID, req.Name, req.Pagination, req.Sortable) + repositoryObjs, total, err := repositoryService.ListRepositoryWithAuth(ctx, namespaceObj.ID, user.ID, req.Name, req.Pagination, req.Sortable) if err != nil { log.Error().Err(err).Msg("List repository failed") return xerrors.NewHTTPError(c, xerrors.HTTPErrCodeInternalError, err.Error()) } - var repositoryIDs = make([]int64, 0, len(repositories)) - for _, repository := range repositories { + var repositoryIDs = make([]int64, 0, len(repositoryObjs)) + for _, repository := range repositoryObjs { repositoryIDs = append(repositoryIDs, repository.ID) } builderService := h.builderServiceFactory.New() @@ -103,8 +104,8 @@ func (h *handler) ListRepositories(c echo.Context) error { return xerrors.NewHTTPError(c, xerrors.HTTPErrCodeInternalError, fmt.Sprintf("Find builders with repository failed: %v", err)) } - var resp = make([]any, 0, len(repositories)) - for _, repository := range repositories { + var resp = make([]any, 0, len(repositoryObjs)) + for _, repository := range repositoryObjs { repositoryObj := types.RepositoryItem{ ID: repository.ID, Name: repository.Name, @@ -115,8 +116,8 @@ func (h *handler) ListRepositories(c echo.Context) error { Size: ptr.Of(repository.Size), TagCount: repository.TagCount, TagLimit: ptr.Of(repository.TagLimit), - CreatedAt: repository.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: repository.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*repository.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*repository.CreatedAt).UTC().Format(consts.DefaultTimePattern), } if builderMap != nil && builderMap[repository.ID] != nil { builderObj := builderMap[repository.ID] diff --git a/pkg/handlers/tags/tags_get.go b/pkg/handlers/tags/tags_get.go index e270f027..018c6604 100644 --- a/pkg/handlers/tags/tags_get.go +++ b/pkg/handlers/tags/tags_get.go @@ -15,6 +15,8 @@ package tag import ( + "time" + "github.com/labstack/echo/v4" "github.com/rs/zerolog/log" "gorm.io/gorm" @@ -91,8 +93,8 @@ func (h *handler) GetTag(c echo.Context) error { PushedAt: item.PushedAt.Format(consts.DefaultTimePattern), Vulnerability: string(item.Vulnerability.Result), Sbom: string(item.Sbom.Result), - CreatedAt: item.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: item.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*item.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*item.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } @@ -110,12 +112,12 @@ func (h *handler) GetTag(c echo.Context) error { PushedAt: tag.Artifact.PushedAt.Format(consts.DefaultTimePattern), Vulnerability: string(tag.Artifact.Vulnerability.Result), Sbom: string(tag.Artifact.Sbom.Result), - CreatedAt: tag.Artifact.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: tag.Artifact.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*tag.Artifact.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*tag.Artifact.CreatedAt).UTC().Format(consts.DefaultTimePattern), }, Artifacts: artifacts, PushedAt: tag.PushedAt.Format(consts.DefaultTimePattern), - CreatedAt: tag.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: tag.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*tag.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*tag.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } diff --git a/pkg/handlers/tags/tags_list.go b/pkg/handlers/tags/tags_list.go index 767aa44c..e6d6032d 100644 --- a/pkg/handlers/tags/tags_list.go +++ b/pkg/handlers/tags/tags_list.go @@ -18,6 +18,7 @@ import ( "errors" "fmt" "net/http" + "time" "github.com/labstack/echo/v4" "github.com/rs/zerolog/log" @@ -132,8 +133,8 @@ func (h *handler) ListTag(c echo.Context) error { PushedAt: item.PushedAt.Format(consts.DefaultTimePattern), Vulnerability: string(item.Vulnerability.Result), Sbom: string(item.Sbom.Result), - CreatedAt: item.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: item.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*item.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*item.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } resp = append(resp, types.TagItem{ @@ -153,14 +154,14 @@ func (h *handler) ListTag(c echo.Context) error { PushedAt: tag.Artifact.PushedAt.Format(consts.DefaultTimePattern), Vulnerability: string(tag.Artifact.Vulnerability.Result), Sbom: string(tag.Artifact.Sbom.Result), - CreatedAt: tag.Artifact.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: tag.Artifact.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*tag.Artifact.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*tag.Artifact.CreatedAt).UTC().Format(consts.DefaultTimePattern), }, Artifacts: artifacts, PullTimes: tag.PullTimes, PushedAt: tag.PushedAt.Format(consts.DefaultTimePattern), - CreatedAt: tag.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: tag.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*tag.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*tag.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } diff --git a/pkg/handlers/users/users_list.go b/pkg/handlers/users/users_list.go index 395a7b02..17d486e6 100644 --- a/pkg/handlers/users/users_list.go +++ b/pkg/handlers/users/users_list.go @@ -16,6 +16,7 @@ package users import ( "net/http" + "time" "github.com/labstack/echo/v4" "github.com/rs/zerolog/log" @@ -65,18 +66,17 @@ func (h *handler) List(c echo.Context) error { return xerrors.NewHTTPError(c, xerrors.HTTPErrCodeInternalError, err.Error()) } var resp = make([]any, 0, len(userObjs)) - for _, o := range userObjs { + for _, userObj := range userObjs { resp = append(resp, types.UserItem{ - ID: o.ID, - Username: o.Username, - Email: ptr.To(o.Email), - Status: o.Status, - LastLogin: o.LastLogin.Format(consts.DefaultTimePattern), - NamespaceLimit: o.NamespaceLimit, - NamespaceCount: o.NamespaceCount, - - CreatedAt: o.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: o.UpdatedAt.Format(consts.DefaultTimePattern), + ID: userObj.ID, + Username: userObj.Username, + Email: ptr.To(userObj.Email), + Status: userObj.Status, + LastLogin: userObj.LastLogin.Format(consts.DefaultTimePattern), + NamespaceLimit: userObj.NamespaceLimit, + NamespaceCount: userObj.NamespaceCount, + CreatedAt: time.Unix(0, int64(time.Millisecond)*userObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*userObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } diff --git a/pkg/handlers/webhooks/webhooks_get.go b/pkg/handlers/webhooks/webhooks_get.go index 21161f85..13df3caa 100644 --- a/pkg/handlers/webhooks/webhooks_get.go +++ b/pkg/handlers/webhooks/webhooks_get.go @@ -18,6 +18,7 @@ import ( "errors" "fmt" "net/http" + "time" "github.com/labstack/echo/v4" "github.com/rs/zerolog/log" @@ -76,7 +77,7 @@ func (h *handler) GetWebhook(c echo.Context) error { EventTag: webhookObj.EventTag, EventArtifact: webhookObj.EventArtifact, EventMember: webhookObj.EventMember, - CreatedAt: webhookObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: webhookObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*webhookObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*webhookObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } diff --git a/pkg/handlers/webhooks/webhooks_list.go b/pkg/handlers/webhooks/webhooks_list.go index d6beb4eb..a31e2342 100644 --- a/pkg/handlers/webhooks/webhooks_list.go +++ b/pkg/handlers/webhooks/webhooks_list.go @@ -16,6 +16,7 @@ package webhooks import ( "net/http" + "time" "github.com/labstack/echo/v4" "github.com/rs/zerolog/log" @@ -74,8 +75,8 @@ func (h *handler) ListWebhook(c echo.Context) error { EventTag: webhookObj.EventTag, EventArtifact: webhookObj.EventArtifact, EventMember: webhookObj.EventMember, - CreatedAt: webhookObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: webhookObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*webhookObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*webhookObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } return c.JSON(http.StatusOK, types.CommonList{Total: total, Items: resp}) diff --git a/pkg/handlers/webhooks/webhooks_log.go b/pkg/handlers/webhooks/webhooks_log.go index 3ed4fde7..8e2602ed 100644 --- a/pkg/handlers/webhooks/webhooks_log.go +++ b/pkg/handlers/webhooks/webhooks_log.go @@ -18,6 +18,7 @@ import ( "errors" "fmt" "net/http" + "time" "github.com/labstack/echo/v4" "github.com/rs/zerolog/log" @@ -80,7 +81,7 @@ func (h *handler) LogWebhook(c echo.Context) error { ReqBody: string(webhookLogObj.ReqBody), RespHeader: string(webhookLogObj.RespHeader), RespBody: string(webhookLogObj.RespBody), - CreatedAt: webhookLogObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: webhookLogObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*webhookLogObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*webhookLogObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } diff --git a/pkg/handlers/webhooks/webhooks_logs.go b/pkg/handlers/webhooks/webhooks_logs.go index 3fe63ecf..bf639167 100644 --- a/pkg/handlers/webhooks/webhooks_logs.go +++ b/pkg/handlers/webhooks/webhooks_logs.go @@ -16,6 +16,7 @@ package webhooks import ( "net/http" + "time" "github.com/labstack/echo/v4" "github.com/rs/zerolog/log" @@ -69,8 +70,8 @@ func (h *handler) LogsWebhook(c echo.Context) error { ReqBody: string(webhookLogObj.ReqBody), RespHeader: string(webhookLogObj.RespHeader), RespBody: string(webhookLogObj.RespBody), - CreatedAt: webhookLogObj.CreatedAt.Format(consts.DefaultTimePattern), - UpdatedAt: webhookLogObj.UpdatedAt.Format(consts.DefaultTimePattern), + CreatedAt: time.Unix(0, int64(time.Millisecond)*webhookLogObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), + UpdatedAt: time.Unix(0, int64(time.Millisecond)*webhookLogObj.CreatedAt).UTC().Format(consts.DefaultTimePattern), }) } return c.JSON(http.StatusOK, types.CommonList{Total: total, Items: resp}) diff --git a/web/src/pages/Namespace/TableItem.tsx b/web/src/pages/Namespace/TableItem.tsx index 051bea0e..0ca8858d 100644 --- a/web/src/pages/Namespace/TableItem.tsx +++ b/web/src/pages/Namespace/TableItem.tsx @@ -16,6 +16,8 @@ import axios from "axios"; import dayjs from 'dayjs'; +import utc from 'dayjs/plugin/utc'; +import timezone from 'dayjs/plugin/timezone'; import { useNavigate } from 'react-router-dom'; import { useEffect, useState, Fragment } from "react"; import relativeTime from 'dayjs/plugin/relativeTime'; @@ -30,6 +32,8 @@ import { INamespaceItem, IHTTPError } from "../../interfaces"; import Quota from "../../components/Quota"; import QuotaSimple from "../../components/QuotaSimple"; +dayjs.extend(utc); +dayjs.extend(timezone); dayjs.extend(relativeTime); export default function TableItem({ localServer, index, namespace, setRefresh }: { localServer: string, index: number, namespace: INamespaceItem, setRefresh: (param: any) => void }) { @@ -144,10 +148,10 @@ export default function TableItem({ localServer, index, namespace, setRefresh }: {namespace.visibility} - {dayjs().to(dayjs(namespace.created_at))} + {dayjs.utc(namespace.created_at).tz(dayjs.tz.guess()).format("YYYY-MM-DD HH:mm:ss")} - {dayjs().to(dayjs(namespace.updated_at))} + {dayjs.utc(namespace.updated_at).tz(dayjs.tz.guess()).format("YYYY-MM-DD HH:mm:ss")} { e.stopPropagation();