-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
564 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
use uuid::Uuid; | ||
|
||
#[derive(Clone)] | ||
pub struct AuthorizedRecipient { | ||
pub project_id: Uuid, | ||
pub recipient_id: Uuid, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
pub mod credentials; | ||
pub mod engine; | ||
pub mod error; | ||
pub mod http; | ||
pub mod pipeline; | ||
pub mod recipient; | ||
pub mod templater; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[package] | ||
name = "notifico-ncenter" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
axum = { workspace = true } | ||
serde = { version = "1.0.210", features = ["derive"] } | ||
sea-orm = { workspace = true } | ||
async-trait = "0.1.83" | ||
uuid = { version = "1.10.0", features = ["v7"] } | ||
chrono = "0.4.38" | ||
serde_json = "1.0.128" | ||
anyhow = "1.0.89" | ||
|
||
notifico-core = { path = "../notifico-core" } | ||
notifico-ncenter-migration = { path = "migration" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[package] | ||
name = "notifico-ncenter-migration" | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[lib] | ||
name = "migration" | ||
path = "src/lib.rs" | ||
|
||
[dependencies] | ||
async-std = { version = "1", features = ["attributes", "tokio1"] } | ||
sea-orm-migration = { workspace = true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Running Migrator CLI | ||
|
||
- Generate a new migration file | ||
```sh | ||
cargo run -- generate MIGRATION_NAME | ||
``` | ||
- Apply all pending migrations | ||
```sh | ||
cargo run | ||
``` | ||
```sh | ||
cargo run -- up | ||
``` | ||
- Apply first 10 pending migrations | ||
```sh | ||
cargo run -- up -n 10 | ||
``` | ||
- Rollback last applied migrations | ||
```sh | ||
cargo run -- down | ||
``` | ||
- Rollback last 10 applied migrations | ||
```sh | ||
cargo run -- down -n 10 | ||
``` | ||
- Drop all tables from the database, then reapply all migrations | ||
```sh | ||
cargo run -- fresh | ||
``` | ||
- Rollback all applied migrations, then reapply all migrations | ||
```sh | ||
cargo run -- refresh | ||
``` | ||
- Rollback all applied migrations | ||
```sh | ||
cargo run -- reset | ||
``` | ||
- Check the status of all migrations | ||
```sh | ||
cargo run -- status | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
pub use sea_orm_migration::prelude::*; | ||
|
||
mod m20220101_000001_create_table; | ||
|
||
pub struct Migrator; | ||
|
||
#[async_trait::async_trait] | ||
impl MigratorTrait for Migrator { | ||
fn migrations() -> Vec<Box<dyn MigrationTrait>> { | ||
vec![Box::new(m20220101_000001_create_table::Migration)] | ||
} | ||
|
||
fn migration_table_name() -> DynIden { | ||
Alias::new("ncenter_migrations").into_iden() | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
notifico-ncenter/migration/src/m20220101_000001_create_table.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use sea_orm_migration::{prelude::*, schema::*}; | ||
|
||
#[derive(DeriveMigrationName)] | ||
pub struct Migration; | ||
|
||
#[async_trait::async_trait] | ||
impl MigrationTrait for Migration { | ||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { | ||
manager | ||
.create_table( | ||
Table::create() | ||
.table(NcenterNotification::Table) | ||
.if_not_exists() | ||
.col(pk_uuid(NcenterNotification::Id)) | ||
.col(uuid(NcenterNotification::RecipientId)) | ||
.col(uuid(NcenterNotification::ProjectId)) | ||
.col(json_binary(NcenterNotification::Content)) | ||
.col(date_time(NcenterNotification::CreatedAt)) | ||
.to_owned(), | ||
) | ||
.await?; | ||
manager | ||
.create_index( | ||
Index::create() | ||
.name("idx_ncenter_notifications_recipient_id") | ||
.table(NcenterNotification::Table) | ||
.if_not_exists() | ||
.col(NcenterNotification::RecipientId) | ||
.col(NcenterNotification::ProjectId) | ||
.to_owned(), | ||
) | ||
.await | ||
} | ||
|
||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { | ||
manager | ||
.drop_table(Table::drop().table(NcenterNotification::Table).to_owned()) | ||
.await | ||
} | ||
} | ||
|
||
#[derive(DeriveIden)] | ||
enum NcenterNotification { | ||
Table, | ||
Id, | ||
RecipientId, | ||
ProjectId, | ||
Content, | ||
CreatedAt, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use sea_orm_migration::prelude::*; | ||
|
||
#[async_std::main] | ||
async fn main() { | ||
cli::run_cli(migration::Migrator).await; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 | ||
pub mod prelude; | ||
|
||
pub mod ncenter_notification; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 | ||
pub use super::ncenter_notification::Entity as NcenterNotification; |
Oops, something went wrong.