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

Commit

Permalink
feat: Testable Migrations (SDK) (#146)
Browse files Browse the repository at this point in the history
* Added migration generator
* Split migrations to dialects for more stable migrations
* Updated Protocol to v4

Co-authored-by: Kemal Hadimli <[email protected]>
  • Loading branch information
disq and disq authored Jan 18, 2022
1 parent ea6f8c5 commit a614380
Show file tree
Hide file tree
Showing 44 changed files with 2,264 additions and 842 deletions.
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

0 comments on commit a614380

Please sign in to comment.