supabase / dbdev

Database Package Registry for Postgres
https://database.dev/
Apache License 2.0
370 stars 19 forks source link

add support for `default_version` in control file #153

Closed imor closed 9 months ago

imor commented 10 months ago

What kind of change does this PR introduce?

feature

What is the current behavior?

default_version key in the control file is not sent to the backend when a user runs dbdev publish. This results in TLE's default version being the first installed version which is usually the oldest version.

What is the new behavior?

The default_version is now tracked in the app.packages table in the default_version_struct and default_version columns. The dbdev CLI also sends the default_version from the control file to the backend when running dbdev publish command. The CLI also checks that the default_version in the control file is one of the valid versions of the package. The in-db client has been updated to fetch the default_version from the public.packages view and call the pgtle.set_default_version function.

Because old dbdev CLI versions are not aware of default_version, the default_version_struct and default_version columns in app.packages are nullable for backward compatibility with those older CLI versions.

Additional context

Fixes #147

vercel[bot] commented 10 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
dbdev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 3, 2024 0:02am
imor commented 9 months ago

Because old dbdev CLI versions are not aware of default_version, the default_version_struct and default_version columns in app.packages are nullable for backward compatibility with those older CLI versions.

The current user base is like 5 people and we're pre-1.0. I think it's worth taking a breaking change thats solvable with a CLI upgrade to avoid having to make the field nullable at this point. wdyt?

default_version is important to be set so making it non-nullable definitely reduces chances of bugs with the added benefit of making the code in this PR a lot simpler. So let me make this change.