Skip to content

Make Status read only#242

Merged
amacneil merged 2 commits intoamacneil:mainfrom
Zimpler:make_status_readonly
Jan 30, 2022
Merged

Make Status read only#242
amacneil merged 2 commits intoamacneil:mainfrom
Zimpler:make_status_readonly

Conversation

@Jell
Copy link
Copy Markdown
Contributor

@Jell Jell commented Oct 6, 2021

So we have this use case where our developers have read-only access to our databases, and want to be able to run dbmate status before running a migration as part of our CI/CD pipeline.

Surprisingly, dbmate status has the potential side-effect of creating the migrations table if it's not there, which fails for a read only user.

This change makes the Status command read only by checking if the table exists, and returning all migrations as pending if it doesn't (and works as expected otherwise).

@Jell
Copy link
Copy Markdown
Contributor Author

Jell commented Dec 10, 2021

anything I could do to help move this forward?

@Enrico204
Copy link
Copy Markdown
Contributor

Interesting. I agree, status should be R/O, there is no need for it to create a table

Comment thread pkg/driver/sqlite/sqlite_test.go Outdated
@Jell Jell force-pushed the make_status_readonly branch from fe7a0ad to ff329c8 Compare January 30, 2022 14:14
@amacneil
Copy link
Copy Markdown
Owner

Would be good to add a test making sure the table doesn’t get created before we merge

@Jell
Copy link
Copy Markdown
Contributor Author

Jell commented Jan 30, 2022

Would be good to add a test making sure the table doesn’t get created before we merge

Done! 7c76b9b

@amacneil
Copy link
Copy Markdown
Owner

Thanks!

@amacneil amacneil merged commit 1c2e5e5 into amacneil:main Jan 30, 2022
@Jell Jell deleted the make_status_readonly branch January 30, 2022 18:55
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.

3 participants