Skip to content
This repository has been archived by the owner on Aug 12, 2022. It is now read-only.

feat: Testable Migrations (SDK) #146

Merged
merged 59 commits into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
3f488d6
Table Creator to migration generator
disq Jan 6, 2022
a720d16
Tear out sqlbuilder
disq Jan 6, 2022
79095d3
Diff migrations
disq Jan 7, 2022
46a8b1a
Add cli handler
disq Jan 7, 2022
598a1b2
Get ctx
disq Jan 7, 2022
1b16a49
Do the types in down migrations
disq Jan 7, 2022
c8e22ef
Find renames
disq Jan 7, 2022
14bd87b
Handle CREATE TABLE in UpgradeTable path
disq Jan 10, 2022
0377d8e
linting
disq Jan 10, 2022
4b5c794
Keep TableCreator signature for now, add plugin version 4 support
disq Jan 10, 2022
62ef6c8
Use consts for proto versions
disq Jan 10, 2022
5a3f99a
define Vunmanaged
disq Jan 10, 2022
42f9b75
Attempt to do the migrations hook
disq Jan 10, 2022
c23aadb
NotNull creation option, add cq_fetch_date to default columns
disq Jan 11, 2022
6cf040f
Fix tests for cq_fetch_date and meta->cq_meta rename
disq Jan 11, 2022
50f6035
not null cq_id
disq Jan 11, 2022
c01cb20
Always handle migrations in the same order
disq Jan 11, 2022
cbd96d4
Fix more tests
disq Jan 11, 2022
3e50d03
Add dialect
disq Jan 11, 2022
0d23e53
Dialectify migrations
disq Jan 11, 2022
4e6b8a8
cli migration helper: Generate separate files for separate dialects
disq Jan 11, 2022
c6dbfc8
Move migrations up, as migration
disq Jan 13, 2022
e4637ef
More dialect stuff
disq Jan 13, 2022
d810ee9
Move migrator elsewhere, use dialect directory
disq Jan 13, 2022
78523a5
migrator.NewMigrator -> migrator.New
disq Jan 13, 2022
51e2eb9
Register timescale scheme, use parser helper in DSNtoDialect
disq Jan 13, 2022
f5d125b
migrator: Add postHook to every call
disq Jan 13, 2022
3f0fc9a
Remove GetDefaultSDKColumns, fix tests
disq Jan 13, 2022
1c3be00
Remove inject fields test
disq Jan 13, 2022
f0f8148
dialect: Remove SupportsForeignKeys(), add Extra() for indexes
disq Jan 14, 2022
ae28cbb
tsdb: FK information as comments
disq Jan 14, 2022
40a1b0d
Fix dialect-specific migration handling
disq Jan 14, 2022
b50cd11
Use schema.QueryExecer instead of pool
disq Jan 14, 2022
ffd5b68
Remove V2 and V3 proto compat
disq Jan 14, 2022
5d437de
Fixes around constraint names and DSN replacements
disq Jan 14, 2022
2a1d236
Fix ResourceValues, resolve cqId last
disq Jan 14, 2022
587ed06
lint
disq Jan 14, 2022
ab91afb
CR feedback
disq Jan 15, 2022
86afefc
More CR feedback
disq Jan 15, 2022
75ef915
cqproto: Migrations by dialect
disq Jan 15, 2022
96199af
migration cli prefix fixes
disq Jan 16, 2022
b7a42f9
gocritic fix
disq Jan 16, 2022
69cdd90
Generate CQ ID ignoring internal column values, CR nits
disq Jan 16, 2022
3c20c3e
schema.Database => schema.Storage
disq Jan 16, 2022
a247d08
Update CLI migrator
disq Jan 16, 2022
8e7f5aa
cli migrator: Add -schema param to filter other schemas
disq Jan 16, 2022
fcf06f2
dialect: Remove FKs-as-comments, call DEFINE_FK instead
disq Jan 17, 2022
4e7f5c4
tsdb: Add parent-table FN, better fn names
disq Jan 17, 2022
a9e40bb
Generate CQ ID fix
disq Jan 17, 2022
f7316a3
setup_tsdb_trigger => setup_tsdb_child
disq Jan 17, 2022
5b2bfd7
Add migration test builder
disq Jan 17, 2022
9102a15
Add SetDSNElement to helpers
disq Jan 17, 2022
a99193f
Move DSN helpers to its own package: database/dsn
disq Jan 17, 2022
db9de39
Address CR
disq Jan 17, 2022
a200311
Column tweaking
disq Jan 17, 2022
7670f98
Update SQL formatting
disq Jan 17, 2022
b9c9ab8
CR: minor nits
disq Jan 18, 2022
832b00c
migrator: Use constants for "version"s
disq Jan 18, 2022
bdc9bc5
Merge branch 'main' into feat/all-migrations-as-files
roneli Jan 18, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions cqproto/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (g GRPCClient) GetProviderSchema(ctx context.Context, _ *GetProviderSchemaR
Name: res.GetName(),
Version: res.GetVersion(),
ResourceTables: tablesFromProto(res.GetResourceTables()),
Migrations: res.Migrations,
Migrations: migrationsFromProto(res.GetMigrations()),
}

return resp, nil
Expand Down Expand Up @@ -116,7 +116,7 @@ func (g *GRPCServer) GetProviderSchema(ctx context.Context, _ *internal.GetProvi
Name: resp.Name,
Version: resp.Version,
ResourceTables: tablesToProto(resp.ResourceTables),
Migrations: resp.Migrations,
Migrations: migrationsToProto(resp.Migrations),
}, nil

}
Expand Down Expand Up @@ -369,3 +369,21 @@ func PartialFetchToCQProto(in []schema.ResourceFetchError) []*FailedResourceFetc
}
return failedResources
}

func migrationsFromProto(in map[string]*internal.DialectMigration) map[string]map[string][]byte {
ret := make(map[string]map[string][]byte, len(in))
for k := range in {
ret[k] = in[k].Migrations
}
return ret
}

func migrationsToProto(in map[string]map[string][]byte) map[string]*internal.DialectMigration {
ret := make(map[string]*internal.DialectMigration, len(in))
for k := range in {
ret[k] = &internal.DialectMigration{
Migrations: in[k],
}
}
return ret
}
Loading