Thanks, that's exactly what I'm looking for. Because our server is an open source product, and the administrator may be upgrading from any version to any version, with multiple nodes, we cannot safely remove any columns unfortunately. Our best strategy is to wait for major version releases to drop the columns, and provide an upgrade path that guides users through a series of backward compatible versions - and hope they read the documentation!
On Tue, Aug 29, 2017 at 10:45 AM, Jeremy Evans <[email protected]> wrote: > On Monday, August 28, 2017 at 4:10:56 PM UTC-7, Beth Skurrie wrote: >> >> We're following a zero-downtime database migration strategy, so we only >> ever add columns, and don't delete the old ones. Is there a way to tell the >> model to ignore the deprecated columns so that there are no accessor >> methods created for them? >> > > Sequel currently creates accessor methods for all columns by default, but > you can always just remove them: > > class ModelName < Sequel::Model > [:deprecated_col1, :deprecated_col2, :deprecated_col3].each do |col| > overridable_methods_module.send(:remove_method, col) > overridable_methods_module.send(:remove_method, :"#{col}=") > end > end > > Note that just leaving the columns available indefinitely is not the best > strategy for a zero-downtime migrations. For zero-downtime migrations, you > should set a manual selection for the model's dataset: > > class ModelName < Sequel::Model(DB[:model].select(:col1, :col2, :col3)) > end > > You also need to make sure that all queries that use the model in your > application select specific columns which do not include the columns you > want to remove. > > Put a new version of your application into production. After all old > versions of your application are no longer running, you can then run a > migration to remove the unused column. Assuming you are using a database > that doesn't rewrite the table when removing a column, there should be no > significant downtime, but that's something you would definitely want to > test before relying on it. > > Thanks, > Jeremy > > -- > You received this message because you are subscribed to a topic in the > Google Groups "sequel-talk" group. > To unsubscribe from this topic, visit https://groups.google.com/d/ > topic/sequel-talk/eJEK068-FeU/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/sequel-talk. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
