mirror of
https://github.com/4cuck/nitter-status.git
synced 2026-10-27 00:57:39 +00:00
keep latest healthcheck errors, basic admin login
This commit is contained in:
1 parent
cc70134d9d
commit
759963e7b2
32 files changed
+1761
-308
No files matched your search
@@ -4,6 +4,8 @@
|
||||
|
||||
New entities:
|
||||
|
||||
`sea-orm-cli migrate generate --migration-dir "migration" --database-url "./sqlite.db?mode=rwc" <name>`
|
||||
|
||||
Run the following command to re-generate the entities.
|
||||
`sea-orm-cli generate entity -o entities/src --with-serde serialize`
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ mod m20230729_230909_datetime_int_host;
|
||||
mod m20230803_154714_version_url;
|
||||
mod m20230829_201916_country;
|
||||
mod m20230914_231514_connectivity;
|
||||
mod m20231011_231223_errors;
|
||||
|
||||
|
||||
|
||||
pub struct Migrator;
|
||||
@@ -20,6 +22,7 @@ impl MigratorTrait for Migrator {
|
||||
Box::new(m20230803_154714_version_url::Migration),
|
||||
Box::new(m20230829_201916_country::Migration),
|
||||
Box::new(m20230914_231514_connectivity::Migration),
|
||||
Box::new(m20231011_231223_errors::Migration),
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -90,13 +90,4 @@ impl MigrationTrait for Migration {
|
||||
async fn down(&self, _manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
panic!("Can't migrate down");
|
||||
}
|
||||
}
|
||||
|
||||
/// Learn more at https://docs.rs/sea-query#iden
|
||||
#[derive(Iden)]
|
||||
enum Post {
|
||||
Table,
|
||||
Id,
|
||||
Title,
|
||||
Text,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
use sea_orm_migration::prelude::*;
|
||||
|
||||
#[derive(DeriveMigrationName)]
|
||||
pub struct Migration;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl MigrationTrait for Migration {
|
||||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
let cmd = r#"CREATE TABLE "check_errors" (
|
||||
"time" integer NOT NULL,
|
||||
"host" integer NOT NULL,
|
||||
"message" text NOT NULL,
|
||||
"http_body" text,
|
||||
"http_status" integer,
|
||||
CONSTRAINT "pk_check_errors" PRIMARY KEY ("host", "time"),
|
||||
FOREIGN KEY ("host") REFERENCES "host" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) WITHOUT ROWID, STRICT;"#;
|
||||
let db = manager.get_connection();
|
||||
db.execute_unprepared("BEGIN EXCLUSIVE").await?;
|
||||
tracing::info!("adding check_errors table..");
|
||||
db.execute_unprepared(cmd).await?;
|
||||
db.execute_unprepared("COMMIT TRANSACTION").await?;
|
||||
db.execute_unprepared("VACUUM").await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn down(&self, _manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
panic!("Can't migrate down");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user