Skip to content

Conversation

imor
Copy link
Contributor

@imor imor commented Dec 7, 2023

What kind of change does this PR introduce?

feature

What is the current behavior?

Packages are named username-package, e.g. kiwicopple-pg_idkit.

What is the new behavior?

Packages will be named user@package, e.g. kiwicopple@pg_idkit. Packages published after this change is rolled out can only be installed with new names. Packages published before can still be installed with older naming scheme for compatibility with older dbdev clients. dbdev clients older than 0.0.5 will not be able to install old packages with the new naming scheme. dbdev 0.0.5 (added in this PR) can install all packages with the new naming scheme.

Additional context

N/A

Copy link

vercel bot commented Dec 7, 2023

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 5, 2024 5:16am

@imor
Copy link
Contributor Author

imor commented Dec 7, 2023

The @ makes the new naming scheme feel backwards, maybe because of similarity to email ids. Should the naming scheme be changed to package@username?

create or replace function dbdev.install(
package_name text,
base_url text default 'https://api.database.dev/rest/v1/',
api_key text default 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InhtdXB0cHBsZnZpaWZyYndtbXR2Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2ODAxMDczNzIsImV4cCI6MTk5NTY4MzM3Mn0.z2CN0mvO2No8wSi46Gw59DFGCTJrzM0AQKsu_5k134s'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not for this PR, but we do need to figure out how to deploy clients without baking in the anon key.

@tiniscule
Copy link

Sorry to chime in here, but when you say packages can be installed using the old way if they existed prior, does that mean that basejump_core would always be installed as basejump-basejump_core, or would it just always work as both?

It's only important because you can't change the installed package name without data loss as far as I know, so just creates a split flow for new/old users of an extension.

@imor
Copy link
Contributor Author

imor commented Jan 3, 2024

Sorry to chime in here, but when you say packages can be installed using the old way if they existed prior, does that mean that basejump_core would always be installed as basejump-basejump_core, or would it just always work as both?

It would work as both for now but the old naming scheme is soft-deprecated by e.g. only showing the new scheme on database.dev. If someone installs using basejump-basejump_core as the name, they can only switch to basejump@basejump_core if they drop and uninstall the extension named basejump-basejump_core and reinstall the new basejump@basejump_core extension.

It's only important because you can't change the installed package name without data loss as far as I know, so just creates a split flow for new/old users of an extension.

If by data loss you mean that the extension needs to be reinstalled then this is true but I don't see a way around Postgres treating the two naming schemes as different extensions. So even though the following two will install the exact same extension in terms of the functionality, they are different extensions as far as Postgres is concerned:

  1. create extension "basejump-basejump_core" version '0.0.1';
  2. create extension "basejump@basejump_core" version '0.0.1';

Since dbdev is still not 1.0 this is the right time to make this change. Thoughts?

@tiniscule
Copy link

Yeah, understand the thinking on your end, just wondering about the words "soft deprecated" and "for now" and what those mean longer term.

I ask because basejump is used in my own projects as well, and if it won't be supported with the current install path I'll need to figure out a way to both migrate my own projects to the new format as well as any users. Since it installs tables/functions used for auth/billing, would just be important for me to find a way to do it smoothly.

Do you intend on maintaining the old install path indefinitely or should I figure it out sooner than later?

Base automatically changed from add_default_version to master January 3, 2024 16:16
@imor
Copy link
Contributor Author

imor commented Jan 4, 2024

Do you intend on maintaining the old install path indefinitely or should I figure it out sooner than later?

We intend to keep only the new naming scheme in the long term, so it's better if you could upgrade sooner rather than later. Would something like the following work for you for upgrading without downtime to the extension with the new naming scheme?:

-- start a transaction
begin;

-- drop extension with old naming scheme
drop extension "basejump-basejump_core";
-- uninstall extension with old naming scheme
select pgtle.uninstall_extension('basejump-basejump_core');

-- install extension with new naming scheme
select dbdev.install('basejump@basejump_core');
-- create extension with new naming scheme
create extension "basejump@basejump_core";

-- commit the transaction
commit;

@tiniscule
Copy link

tiniscule commented Jan 4, 2024

I'll give it a shot, but I'm pretty sure that'll result in all the tables created by basejump-basejump_core being deleted and then identical empty tables being created by basejump@basejump_core.

Will play around with options now that I know it's deprecating. Thanks for the quick responses.

@imor
Copy link
Contributor Author

imor commented Jan 5, 2024

I'll give it a shot, but I'm pretty sure that'll result in all the tables created by basejump-basejump_core being deleted and then identical empty tables being created by basejump@basejump_core.

Will play around with options now that I know it's deprecating. Thanks for the quick responses.

You are right, data in objects created by a TLE will need to be migrated manually.

@imor imor closed this Jan 5, 2024
@imor imor reopened this Jan 5, 2024
@imor imor merged commit a764b6f into master Jan 5, 2024
@imor imor deleted the new_naming_scheme branch January 5, 2024 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants