Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dialect/sql/schema: file based type store (#2644)
* dialect/sql/schema: file based type store This PR adds support for a file based type storage when using versioned migrations. The file called `.ent_types` is written to the migration directory alongside the migration files and will be kept in sync for every migration file generation run. In order to not break existing code, where the type storage might differ for different deployment, global unique ID mut be enabled by using a new option. This will also be raised as an error to the user when attempting to use versioned migrations and global unique ID. Documentation will be added to this PR once feedback on the code is gathered. * apply CR * fix tests * change format of types file to exclude it from atlas.sum file * docs and drift test * apply CR
- Loading branch information
Showing
12 changed files
with
411 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2019-present Facebook Inc. All rights reserved. | ||
// This source code is licensed under the Apache 2.0 license found | ||
// in the LICENSE file in the root directory of this source tree. | ||
|
||
package schema | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"ariga.io/atlas/sql/migrate" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestDirTypeStore(t *testing.T) { | ||
ex := []string{"a", "b", "c"} | ||
p := t.TempDir() | ||
d, err := migrate.NewLocalDir(p) | ||
require.NoError(t, err) | ||
|
||
s := &dirTypeStore{d} | ||
require.NoError(t, s.save(ex)) | ||
require.FileExists(t, filepath.Join(p, entTypes)) | ||
c, err := os.ReadFile(filepath.Join(p, entTypes)) | ||
require.NoError(t, err) | ||
require.Contains(t, string(c), atlasDirective) | ||
|
||
ac, err := s.load(context.Background(), nil) | ||
require.NoError(t, err) | ||
require.Equal(t, ex, ac) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.