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

已合併
Plume_migration_agent 將 9 次提交從 integrated-migrations 合併至 master 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 年前 (已從 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 (已從 github.com 遷移) 已審核 5 年前
elegaanz (已從 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 年前
發布者
擁有者

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 (已從 github.com 遷移) 已審核 5 年前
igalic (已從 github.com 遷移) 留下了回應

👀

👀
@ -0,0 +48,4 @@
.unwrap()
.chars()
.filter(char::is_ascii_digit)
.take(14)
igalic (已從 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)
發布者
擁有者

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 (已從 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 (已從 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<()> {
發布者
擁有者

no :x

no :x
發布者
擁有者

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 (已從 github.com 遷移) 核可了這些變更 5 年前
elegaanz (已從 github.com 遷移) 留下了回應

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:
發布者
擁有者

@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 年前 (已從 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 😅
發布者
擁有者

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 年前 (已從 github.com 遷移)

Let's say people have a secure configuration. 😄

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

審核者

此合併請求已被合併為 49bb8cb0bc
您也可以查看命令列指南

第一步:

在您的儲存庫中切換到新分支並測試變更。
git checkout -b integrated-migrations master
git pull origin integrated-migrations

第二步:

合併變更並更新到 Forgejo。
git checkout master
git merge --no-ff integrated-migrations
git push origin master
登入 才能加入這對話。
沒有審核者
未選擇里程碑
沒有負責人
2 參與者
通知
截止日期
截止日期無效或超出範圍,請使用「yyyy-mm-dd」的格式。

未設定截止日期。

先決條件

未設定先決條件。

參考: Plume/Plume#555
載入中…
尚未有任何內容