Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prod deploy #2689

Merged
merged 40 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
e0a78dd
fix: bump edge-runtime to 1.58.3 (#2668)
nyannyacha Sep 10, 2024
24ea3cb
feat: allow Cognito configuration from env var (#2660)
tim-dianahr Sep 11, 2024
b409d6a
fix: Health Check issue on Podman/Windows (#2656)
arvalaan Sep 11, 2024
787bc92
feat: add db lint fail-on flag (#2664)
avallete Sep 11, 2024
90220bb
feat: support delete all credentials from keyring
sweatybridge Sep 11, 2024
6003aae
chore: add linux tests dependency
sweatybridge Sep 11, 2024
e60bc21
feat: db reset skip seed flag (#2665)
avallete Sep 11, 2024
3599b8e
chore(deps): bump github.com/docker/cli from 26.1.5+incompatible to 2…
dependabot[bot] Sep 11, 2024
0453ebd
chore(deps): bump golang.org/x/oauth2 from 0.21.0 to 0.23.0 (#2675)
dependabot[bot] Sep 12, 2024
07d3af2
chore(deps): bump golang.org/x/term from 0.22.0 to 0.24.0 (#2676)
dependabot[bot] Sep 12, 2024
cae1ba1
chore(deps): bump github.com/containers/common from 0.59.2 to 0.60.2 …
dependabot[bot] Sep 12, 2024
8093b10
chore(deps): bump go.opentelemetry.io/otel from 1.28.0 to 1.30.0 (#2678)
dependabot[bot] Sep 13, 2024
d5482e0
chore(deps): bump google.golang.org/grpc from 1.65.0 to 1.66.2 (#2680)
dependabot[bot] Sep 13, 2024
e55fef9
chore(deps): bump github.com/slack-go/slack from 0.13.1 to 0.14.0 (#2…
dependabot[bot] Sep 13, 2024
54fa898
feat: add support for multiple output formats (#2674)
djhi Sep 13, 2024
92669a8
feat: add --all flag to stop command (#2672)
avallete Sep 13, 2024
230be7f
fix: logout credentials cleanup (#2670)
avallete Sep 13, 2024
5c0d71b
feat: add no-deploy flag for functions under config.toml
avallete Sep 16, 2024
2440bbd
chore: add debug logs
avallete Sep 16, 2024
9b9bb4a
chore(deps): bump golang.org/x/mod from 0.20.0 to 0.21.0 (#2686)
dependabot[bot] Sep 17, 2024
b0a0488
fix: update deno.unstable settings in VS Code settings.json template …
oxcabe Sep 17, 2024
a537dc0
chore: apply PR comments
avallete Sep 17, 2024
4afe868
chore: extract enabled check into function
avallete Sep 17, 2024
6184f7a
chore: remove redundant comment
avallete Sep 17, 2024
9ba51a9
Merge branch 'develop' into avallete/feat-add-function-no-deploy-logic
avallete Sep 17, 2024
9c1b27a
fix: db test on SELinux enabled systems (#2683)
avallete Sep 17, 2024
3419c0d
chore: Apply suggestions from code review
avallete Sep 18, 2024
963a71e
chore: fix dereference
avallete Sep 18, 2024
3cc5a17
Merge branch 'develop' into avallete/feat-add-function-no-deploy-logic
avallete Sep 18, 2024
7ec843d
feat: add enabled flag for functions under config.toml (#2688)
avallete Sep 18, 2024
044ba61
chore: start command validate exclude arguments
avallete Sep 19, 2024
d660a36
chore: apply PR comments
avallete Sep 20, 2024
cf504ab
feat(realtime): add longpoll route to kong (#2506)
filipecabaco Sep 20, 2024
a66a390
chore: apply comment update cmd/start.go
avallete Sep 20, 2024
4d50bf6
Merge branch 'develop' into avallete/chore-start-command-validate-exc…
avallete Sep 20, 2024
e6ec6ac
chore: start command validate exclude arguments (#2697)
avallete Sep 20, 2024
a0a5d5f
fix: the container ulimits for reatime (#2694)
avallete Sep 20, 2024
cd94f35
fix: handle version prefix in globals (#2701)
sweatybridge Sep 21, 2024
d4b920a
chore: remove cname swap message as it is no longer a requirement
Crispy1975 Sep 17, 2024
5701583
fix: ensure the cli and ui flow for custom domains match
Crispy1975 Sep 20, 2024
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
Prev Previous commit
Next Next commit
feat: db reset skip seed flag (#2665)
* wip

* feat: db reset --skip-seed flag

Add a  flag option to the  command
Closes #2534

* chore: apply suggestions from code review

Co-authored-by: Han Qiao <sweatybridge@gmail.com>

* feat: add db.seed enabled config params

* chore: remove unused type

* Update db.go

* Apply suggestions from code review

---------

Co-authored-by: Han Qiao <sweatybridge@gmail.com>
  • Loading branch information
avallete and sweatybridge authored Sep 11, 2024
commit e60bc21e7f7a55d24885a4f9d8611b464c0f4c78
6 changes: 6 additions & 0 deletions cmd/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,15 @@ var (
},
}

noSeed bool

dbResetCmd = &cobra.Command{
Use: "reset",
Short: "Resets the local database to current migrations",
RunE: func(cmd *cobra.Command, args []string) error {
if noSeed {
utils.Config.Db.Seed.Enabled = false
}
return reset.Run(cmd.Context(), migrationVersion, flags.DbConfig, afero.NewOsFs())
},
}
Expand Down Expand Up @@ -304,6 +309,7 @@ func init() {
resetFlags.String("db-url", "", "Resets the database specified by the connection string (must be percent-encoded).")
resetFlags.Bool("linked", false, "Resets the linked project with local migrations.")
resetFlags.Bool("local", true, "Resets the local database with local migrations.")
resetFlags.BoolVar(&noSeed, "no-seed", false, "Skip running the seed script after reset.")
dbResetCmd.MarkFlagsMutuallyExclusive("db-url", "linked", "local")
resetFlags.StringVar(&migrationVersion, "version", "", "Reset up to the specified version.")
dbCmd.AddCommand(dbResetCmd)
Expand Down
27 changes: 27 additions & 0 deletions internal/db/reset/reset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,33 @@ func TestResetRemote(t *testing.T) {
assert.NoError(t, err)
})

t.Run("resets remote database with seed config disabled", func(t *testing.T) {
// Setup in-memory fs
fsys := afero.NewMemMapFs()
path := filepath.Join(utils.MigrationsDir, "0_schema.sql")
require.NoError(t, afero.WriteFile(fsys, path, nil, 0644))
seedPath := filepath.Join(utils.SeedDataPath)
// Will raise an error when seeding
require.NoError(t, afero.WriteFile(fsys, seedPath, []byte("INSERT INTO test_table;"), 0644))
// Setup mock postgres
conn := pgtest.NewConn()
defer conn.Close(t)
conn.Query(migration.ListSchemas, escapedSchemas).
Reply("SELECT 1", []interface{}{"private"}).
Query("DROP SCHEMA IF EXISTS private CASCADE").
Reply("DROP SCHEMA").
Query(migration.DropObjects).
Reply("INSERT 0")
helper.MockMigrationHistory(conn).
Query(migration.INSERT_MIGRATION_VERSION, "0", "schema", nil).
Reply("INSERT 0 1")
utils.Config.Db.Seed.Enabled = false
// Run test
err := resetRemote(context.Background(), "", dbConfig, fsys, conn.Intercept)
// No error should be raised since we're skipping the seed
assert.NoError(t, err)
})

t.Run("throws error on connect failure", func(t *testing.T) {
// Setup in-memory fs
fsys := afero.NewMemMapFs()
Expand Down
3 changes: 3 additions & 0 deletions internal/migration/apply/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ func MigrateAndSeed(ctx context.Context, version string, conn *pgx.Conn, fsys af
if err := migration.ApplyMigrations(ctx, migrations, conn, afero.NewIOFS(fsys)); err != nil {
return err
}
if !utils.Config.Db.Seed.Enabled {
return nil
}
return SeedDatabase(ctx, conn, fsys)
}

Expand Down
24 changes: 24 additions & 0 deletions internal/migration/apply/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,30 @@ func TestMigrateDatabase(t *testing.T) {
assert.NoError(t, err)
})

t.Run("skip seeding when seed config is disabled", func(t *testing.T) {
// Setup in-memory fs
fsys := afero.NewMemMapFs()
path := filepath.Join(utils.MigrationsDir, "0_test.sql")
sql := "create schema public"
require.NoError(t, afero.WriteFile(fsys, path, []byte(sql), 0644))
seedPath := filepath.Join(utils.SeedDataPath)
// This will raise an error when seeding
require.NoError(t, afero.WriteFile(fsys, seedPath, []byte("INSERT INTO test_table;"), 0644))
// Setup mock postgres
conn := pgtest.NewConn()
defer conn.Close(t)
helper.MockMigrationHistory(conn).
Query(sql).
Reply("CREATE SCHEMA").
Query(migration.INSERT_MIGRATION_VERSION, "0", "test", []string{sql}).
Reply("INSERT 0 1")
utils.Config.Db.Seed.Enabled = false
// Run test
err := MigrateAndSeed(context.Background(), "", conn.MockClient(t), fsys)
// No error should be returned since seeding is skipped
assert.NoError(t, err)
})

t.Run("ignores empty local directory", func(t *testing.T) {
assert.NoError(t, MigrateAndSeed(context.Background(), "", nil, afero.NewMemMapFs()))
})
Expand Down
8 changes: 8 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ type (
Password string `toml:"-"`
RootKey string `toml:"-" mapstructure:"root_key"`
Pooler pooler `toml:"pooler"`
Seed seed `toml:"seed"`
}

seed struct {
Enabled bool `toml:"enabled"`
}

pooler struct {
Expand Down Expand Up @@ -457,6 +462,9 @@ func NewConfig(editors ...ConfigEditor) config {
EncryptionKey: "12345678901234567890123456789032",
SecretKeyBase: "EAx3IQ/wRG1v47ZD4NE4/9RzBI8Jmil3x0yhcW4V2NHBP6c2iPIzwjofi2Ep4HIG",
},
Seed: seed{
Enabled: true,
},
},
Realtime: realtime{
Image: realtimeImage,
Expand Down