mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-09 09:06:36 +08:00
fix(db): 重编号 Pages 部署源迁移避免版本冲突
main 已占用 202607190001(OpenResty 默认限流), 将 Pages source runtime / scanner seed 顺延为 202607190002、202607190003,并同步迁移测试期望配置数。
This commit is contained in:
@@ -368,8 +368,8 @@ PostgreSQL 与 SQLite 均创建同语义的部分唯一索引。禁止用空字
|
|||||||
|
|
||||||
新增双方言 migration:
|
新增双方言 migration:
|
||||||
|
|
||||||
1. `202607190001_add_pages_source_runtime.sql`:两张 source 表、project content version、deployment provenance、索引和存量回填。
|
1. `202607190002_add_pages_source_runtime.sql`:两张 source 表、project content version、deployment provenance、索引和存量回填。
|
||||||
2. `202607190002_seed_pages_source_scan.sql`:幂等插入 `of_pages_source_scan` 的 5 分钟 schedule。
|
2. `202607190003_seed_pages_source_scan.sql`:幂等插入 `of_pages_source_scan` 的 5 分钟 schedule。
|
||||||
|
|
||||||
存量 deployment 只能可靠回填为 `source_type=manual_upload`、`trigger_type=manual_upload`,identity/revision 保持 NULL;现有记录无法反推出是否来自旧一次性 URL。schedule seed 不写死 ID,使用 `WHERE NOT EXISTS (task_type = 'of_pages_source_scan')`,Down 仅按该 task type 删除。
|
存量 deployment 只能可靠回填为 `source_type=manual_upload`、`trigger_type=manual_upload`,identity/revision 保持 NULL;现有记录无法反推出是否来自旧一次性 URL。schedule seed 不写死 ID,使用 `WHERE NOT EXISTS (task_type = 'of_pages_source_scan')`,Down 仅按该 task type 删除。
|
||||||
|
|
||||||
@@ -1143,13 +1143,13 @@ scanner TaskResult 和结构化日志至少记录:
|
|||||||
|
|
||||||
#### [NEW] PostgreSQL
|
#### [NEW] PostgreSQL
|
||||||
|
|
||||||
* `internal/db/migrator/goose/postgres/202607190001_add_pages_source_runtime.sql`
|
* `internal/db/migrator/goose/postgres/202607190002_add_pages_source_runtime.sql`
|
||||||
* `internal/db/migrator/goose/postgres/202607190002_seed_pages_source_scan.sql`
|
* `internal/db/migrator/goose/postgres/202607190003_seed_pages_source_scan.sql`
|
||||||
|
|
||||||
#### [NEW] SQLite
|
#### [NEW] SQLite
|
||||||
|
|
||||||
* `internal/db/migrator/goose/sqlite/202607190001_add_pages_source_runtime.sql`
|
* `internal/db/migrator/goose/sqlite/202607190002_add_pages_source_runtime.sql`
|
||||||
* `internal/db/migrator/goose/sqlite/202607190002_seed_pages_source_scan.sql`
|
* `internal/db/migrator/goose/sqlite/202607190003_seed_pages_source_scan.sql`
|
||||||
|
|
||||||
版本号若已被其它分支占用,实施时只顺延编号,不改变 DDL/DML 拆分。
|
版本号若已被其它分支占用,实施时只顺延编号,不改变 DDL/DML 拆分。
|
||||||
|
|
||||||
|
|||||||
@@ -19,8 +19,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// expectedMigratedSystemConfigCount 包含初始 32 项系统配置、202606220004
|
// expectedMigratedSystemConfigCount 包含初始 32 项系统配置、202606220004
|
||||||
// 从 of_options 迁移过来的 48 项业务配置,以及 Pages 的 2 项业务配置。
|
// 从 of_options 迁移过来的 48 项业务配置、Pages 的 2 项业务配置,
|
||||||
const expectedMigratedSystemConfigCount = 82
|
// 以及 OpenResty 默认限流的 3 项业务配置。
|
||||||
|
const expectedMigratedSystemConfigCount = 85
|
||||||
|
|
||||||
func TestMigrateInitializesSQLiteDatabase(t *testing.T) {
|
func TestMigrateInitializesSQLiteDatabase(t *testing.T) {
|
||||||
sqliteDB, err := gorm.Open(sqlite.Open(":memory:"), &gorm.Config{
|
sqliteDB, err := gorm.Open(sqlite.Open(":memory:"), &gorm.Config{
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
pagesSourcePreviousMigration = int64(202607180001)
|
pagesSourcePreviousMigration = int64(202607190001)
|
||||||
pagesSourceMigration = int64(202607190001)
|
pagesSourceMigration = int64(202607190002)
|
||||||
pagesMigrationProjectID = uint(900001)
|
pagesMigrationProjectID = uint(900001)
|
||||||
pagesMigrationDeploymentID = uint(900001)
|
pagesMigrationDeploymentID = uint(900001)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
pagesSourceScanPreviousMigration = int64(202607190001)
|
pagesSourceScanPreviousMigration = int64(202607190002)
|
||||||
pagesSourceScanMigration = int64(202607190002)
|
pagesSourceScanMigration = int64(202607190003)
|
||||||
pagesSourceScanTaskType = "of_pages_source_scan"
|
pagesSourceScanTaskType = "of_pages_source_scan"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -114,8 +114,8 @@ func runPagesSourceScanScheduleMigration(
|
|||||||
|
|
||||||
func TestPagesSourceScanScheduleMigrationsUseDatabaseGeneratedIDs(t *testing.T) {
|
func TestPagesSourceScanScheduleMigrationsUseDatabaseGeneratedIDs(t *testing.T) {
|
||||||
for _, name := range []string{
|
for _, name := range []string{
|
||||||
"goose/postgres/202607190002_seed_pages_source_scan.sql",
|
"goose/postgres/202607190003_seed_pages_source_scan.sql",
|
||||||
"goose/sqlite/202607190002_seed_pages_source_scan.sql",
|
"goose/sqlite/202607190003_seed_pages_source_scan.sql",
|
||||||
} {
|
} {
|
||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
content, err := migrationFS.ReadFile(name)
|
content, err := migrationFS.ReadFile(name)
|
||||||
@@ -126,7 +126,7 @@ func TestPagesSourceScanScheduleMigrationsUseDatabaseGeneratedIDs(t *testing.T)
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
postgresContent, err := migrationFS.ReadFile("goose/postgres/202607190002_seed_pages_source_scan.sql")
|
postgresContent, err := migrationFS.ReadFile("goose/postgres/202607190003_seed_pages_source_scan.sql")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
compactPostgres := strings.Join(strings.Fields(strings.ToLower(string(postgresContent))), " ")
|
compactPostgres := strings.Join(strings.Fields(strings.ToLower(string(postgresContent))), " ")
|
||||||
assert.Contains(
|
assert.Contains(
|
||||||
|
|||||||
Reference in New Issue
Block a user