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

Generate view definition and migration for updates #23

Closed
calebhearth opened this issue Jul 28, 2014 · 7 comments
Closed

Generate view definition and migration for updates #23

calebhearth opened this issue Jul 28, 2014 · 7 comments
Assignees
Milestone

Comments

@calebhearth
Copy link
Contributor

rails generate view_update searches <= or the like

  • Creates app/views/searches_v2.sql, assuming only one preexisting version. (calculate next version)
  • creates db/migrate/..._update_searches_v2.rb
@calebhearth calebhearth added this to the v0.2.0 milestone Jul 28, 2014
@derekprior
Copy link
Contributor

I think we had planned to re-use rails generate scenic:view searches which would be smart enough to check if searches_v1.sql already exists and adding v2 if it does.

Alternative: rails generate scenic:update searches

@calebhearth
Copy link
Contributor Author

Either are fine with me.

@derekprior
Copy link
Contributor

If I have db/views/searches_v2.sql but have removed v1 - what file gets added? Do I create v1? Or do I detect that v2 is already there and increment to v3?

Should the versioning use the timestamp like migrations to avoid even having to think of this? The obvious downside there is that it's a lot more work to figure out what to put in revert_to unless we default it.

@derekprior
Copy link
Contributor

... and even if we default it, it's still a real pain to figure out what to override it with. The files would still sort sanely (which they actually won't with our current naming scheme (v1, v10, v11, v2, ...).

@calebhearth
Copy link
Contributor Author

Seems fairly simple to me:

%w(foo_v2.sql foo_v10.sql)
  .map { |name| /v(?<version>\d+)\.sql$/.match(name)["version"].to_i }
  .max.next

@calebhearth
Copy link
Contributor Author

I'm also happy to pad versions, but my guess is that they'll rarely get above 9, let alone 99.

@calebhearth calebhearth self-assigned this Aug 5, 2014
@derekprior
Copy link
Contributor

Closed by #33.

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

2 participants