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

create all upsert functions in a dedicated schema so they can be dropped all at once #106

Open
seamusabshere opened this issue Apr 7, 2018 · 7 comments

Comments

@seamusabshere
Copy link
Owner

for example, schema name "upsert_VERSION"

since we control the invocation of the function, we could always invoke it with the upsert_VERSION schema prefix

@searls
Copy link
Contributor

searls commented Jan 6, 2019

👍 my app has enough postgres magic in it that I need to use structure.sql instead of schema.rb for tracking changes, and the rather dense generated upsert functions add quite a lot of churn. Would this help that?

@pnomolos
Copy link
Collaborator

pnomolos commented Jan 6, 2019 via email

@mkaplan9
Copy link

@pnomolos if you're still willing, would love to see that code :)

@pnomolos
Copy link
Collaborator

@mkaplan9 @searls I use Sequel, so you'll need to tweak to fit whatever DB adapter you use, but basically you just need to change the Upsert identifier:

Upsert::MergeFunction::NAME_PREFIX = "upsert"
DB.synchronize do |conn|
  Upsert.clear_database_functions(conn)
end

@mkaplan9
Copy link

Thanks, I found that on this issue yesterday and got it to work. I still don't really understand what Upsert::MergeFunction::NAME_PREFIX = "upsert" does, is there a place I can learn more about it?

@pnomolos
Copy link
Collaborator

@mkaplan9 Normally the upsert functions are versioned (for example: "upsert_1_2"). This just removes that versioning and since it's checking against a regular expression it just removes all the functions called "upsert.*"

@mkaplan9
Copy link

Ah ok that makes sense. Thanks!

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

No branches or pull requests

4 participants