import migrations and don't require diesel_cli for admins #555

병합
Plume_migration_agent integrated-migrations 에서 master 로 9 commits 를 머지했습니다 5 년 전
trinity-1686a 코멘트됨, 5 년 전
소유자

this is an attempt at integrating migrations to plm, with the goal to remove need for diesel_cli, and to allow arbitrary rust in migrations (can come handy for many reasons, like need to upgrade tantivy index version due to upstream changes, without need to take special steps for sysadmins)

  • backbone for the feature
  • integration to plm as new sub-command
  • update ci
  • make plume fail to launch if it detect migrations must be run
this is an attempt at integrating migrations to plm, with the goal to remove need for diesel_cli, and to allow arbitrary rust in migrations (can come handy for many reasons, like need to upgrade tantivy index version due to upstream changes, without need to take special steps for sysadmins) - [x] backbone for the feature - [x] integration to plm as new sub-command - [x] update ci - [x] make plume fail to launch if it detect migrations must be run
codecov[bot] 코멘트됨, 5 년 전 (Migrated from github.com)

Codecov Report

Merging #555 into master will increase coverage by 0.3%.
The diff coverage is 89.91%.

@@            Coverage Diff            @@
##           master     #555     +/-   ##
=========================================
+ Coverage   44.08%   44.39%   +0.3%     
=========================================
  Files          68       70      +2     
  Lines        7937     8044    +107     
=========================================
+ Hits         3499     3571     +72     
- Misses       4438     4473     +35
# [Codecov](https://codecov.io/gh/Plume-org/Plume/pull/555?src=pr&el=h1) Report > Merging [#555](https://codecov.io/gh/Plume-org/Plume/pull/555?src=pr&el=desc) into [master](https://codecov.io/gh/Plume-org/Plume/commit/787eb7f3992e43e7a149288f3378c90dd4fe4bf8?src=pr&el=desc) will **increase** coverage by `0.3%`. > The diff coverage is `89.91%`. ```diff @@ Coverage Diff @@ ## master #555 +/- ## ========================================= + Coverage 44.08% 44.39% +0.3% ========================================= Files 68 70 +2 Lines 7937 8044 +107 ========================================= + Hits 3499 3571 +72 - Misses 4438 4473 +35 ```
elegaanz (Migrated from github.com) 검토됨 5 년 전
elegaanz (Migrated from github.com) 코멘트됨, 5 년 전

Isn't this always true? (maybe not, I'm really bad with Bash)

Isn't this always true? (maybe not, I'm really bad with Bash)
trinity-1686a 검토됨 5 년 전
trinity-1686a 코멘트됨, 5 년 전
포스터
소유자

oops I tested with a value, and forgot to use the variable after 😬

oops I tested with a value, and forgot to use the variable after :grimacing:
igalic (Migrated from github.com) 검토됨 5 년 전
igalic (Migrated from github.com) left a comment

👀

👀
@ -0,0 +48,4 @@
.unwrap()
.chars()
.filter(char::is_ascii_digit)
.take(14)
igalic (Migrated from github.com) 코멘트됨, 5 년 전

this seems like a strange thing to take()
what is this whole expression supposed to do?

this seems like a strange thing to `take()` what is this whole expression supposed to do?
trinity-1686a 검토됨 5 년 전
@ -0,0 +48,4 @@
.unwrap()
.chars()
.filter(char::is_ascii_digit)
.take(14)
trinity-1686a 코멘트됨, 5 년 전
포스터
소유자

diesel store whether migrations were run by storing a 14 digit code. For 2019-03-06-115158_blog_images, it is translated to 20190306115158. To do that I get an iterator over the folder name, filter only digits, and take the first 14 ones (if there are more, they are ignored). See here for take documentation

diesel store whether migrations were run by storing a 14 digit code. For `2019-03-06-115158_blog_images`, it is translated to `20190306115158`. To do that I get an iterator over the folder name, filter only digits, and take the first 14 ones (if there are more, they are ignored). See [here](https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.take) for `take` documentation
elegaanz (Migrated from github.com) 검토됨 5 년 전
@ -0,0 +49,4 @@
pub struct ImportedMigrations(&'static [ComplexMigration]);
impl ImportedMigrations {
pub fn run_pending_migrations(&self, conn: &Connection, path: &Path) -> Result<()> {
elegaanz (Migrated from github.com) 코멘트됨, 5 년 전

Should these dbg! be here?

Should these `dbg!` be here?
trinity-1686a 검토됨 5 년 전
@ -0,0 +49,4 @@
pub struct ImportedMigrations(&'static [ComplexMigration]);
impl ImportedMigrations {
pub fn run_pending_migrations(&self, conn: &Connection, path: &Path) -> Result<()> {
trinity-1686a 코멘트됨, 5 년 전
포스터
소유자

no :x

no :x
trinity-1686a 코멘트됨, 5 년 전
포스터
소유자

At some point the documentation should also be updated to reflect that change

At some point the documentation should also be updated to reflect that change
elegaanz (Migrated from github.com) 이 변경사항을 승인하였습니다. 5 년 전
elegaanz (Migrated from github.com) left a comment

I don't think it would be possible, but creating the PostgreSQL database if it doesn't exist would be perfect.

But it already works fine, so you can merge as it is.

👍

I don't think it would be possible, but creating the PostgreSQL database if it doesn't exist would be perfect. But it already works fine, so you can merge as it is. :+1:
trinity-1686a 코멘트됨, 5 년 전
포스터
소유자

@BaptisteGelez I think it's possible, I'll try to do it (diesel_cli does that from what I saw in it's code)

Edit: apparently it detect a connection error, assume it means the database don't exist, then connect to the same address but without specifying a database, run a query, and then try to reconnect. Considering the first step, this should probably be done in plm, not in plume-models

@BaptisteGelez I think it's possible, I'll try to do it (diesel_cli does that from what I saw in it's code) Edit: apparently it detect a connection error, assume it means the database don't exist, then connect to the same address but without specifying a database, run a query, and then try to reconnect. Considering the first step, this should probably be done in plm, not in plume-models
igalic 코멘트됨, 5 년 전 (Migrated from github.com)

I don't think it would be possible, but creating the PostgreSQL database if it doesn't exist would be perfect.

usually, create db is a more privileged operation than creating anything in that db…
and i sure hope people aren't giving our software that kind of permissions 😅

> I don't think it would be possible, but creating the PostgreSQL database if it doesn't exist would be perfect. usually, create db is a more privileged operation than creating anything in that db… and i sure hope people aren't giving our software that kind of permissions 😅
trinity-1686a 코멘트됨, 5 년 전
포스터
소유자

So, shall I try, or do I assume people have a "secure" configuration that don't allow us to do privileged things?

So, shall I try, or do I assume people have a "secure" configuration that don't allow us to do privileged things?
elegaanz 코멘트됨, 5 년 전 (Migrated from github.com)

Let's say people have a secure configuration. 😄

Let's say people have a secure configuration. :smile:

리뷰어

The pull request has been merged as 49bb8cb0bc.
You can also view command line instructions.

Step 1:

From your project repository, check out a new branch and test the changes.
git checkout -b integrated-migrations master
git pull origin integrated-migrations

Step 2:

Merge the changes and update on Forgejo.
git checkout master
git merge --no-ff integrated-migrations
git push origin master
로그인하여 이 대화에 참여
No reviewers
마일스톤 없음
담당자 없음
참여자 2명
알림
마감일
기한이 올바르지 않거나 범위를 벗어났습니다. 'yyyy-mm-dd'형식을 사용해주십시오.

마감일이 설정되지 않았습니다.

의존성

No dependencies set.

Reference: Plume/Plume#555
불러오는 중...
아직 콘텐츠가 없습니다.