feat: Refactor service management scripts to use a unified dev script
- Added package.json to manage development scripts. - Updated restart-services.ps1 to call the new dev script for starting services. - Refactored start-admin.ps1, start-backend.ps1, start-frontend.ps1, and start-mcp.ps1 to utilize the dev script for starting respective services. - Enhanced stop-services.ps1 to improve process termination logic by matching command patterns.
This commit is contained in:
@@ -17,6 +17,10 @@ mod m20260328_000006_add_ai_to_site_settings;
|
||||
mod m20260328_000007_create_ai_chunks;
|
||||
mod m20260328_000008_enable_pgvector_for_ai_chunks;
|
||||
mod m20260328_000009_add_paragraph_comments;
|
||||
mod m20260328_000010_add_paragraph_comments_toggle_to_site_settings;
|
||||
mod m20260328_000011_add_post_images_and_music_playlist;
|
||||
mod m20260329_000012_add_link_url_to_reviews;
|
||||
mod m20260329_000013_add_ai_provider_presets_to_site_settings;
|
||||
pub struct Migrator;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
@@ -38,6 +42,10 @@ impl MigratorTrait for Migrator {
|
||||
Box::new(m20260328_000007_create_ai_chunks::Migration),
|
||||
Box::new(m20260328_000008_enable_pgvector_for_ai_chunks::Migration),
|
||||
Box::new(m20260328_000009_add_paragraph_comments::Migration),
|
||||
Box::new(m20260328_000010_add_paragraph_comments_toggle_to_site_settings::Migration),
|
||||
Box::new(m20260328_000011_add_post_images_and_music_playlist::Migration),
|
||||
Box::new(m20260329_000012_add_link_url_to_reviews::Migration),
|
||||
Box::new(m20260329_000013_add_ai_provider_presets_to_site_settings::Migration),
|
||||
// inject-above (do not remove this comment)
|
||||
]
|
||||
}
|
||||
|
||||
@@ -42,7 +42,11 @@ impl MigrationTrait for Migration {
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(table.clone())
|
||||
.add_column(ColumnDef::new(Alias::new("paragraph_excerpt")).string().null())
|
||||
.add_column(
|
||||
ColumnDef::new(Alias::new("paragraph_excerpt"))
|
||||
.string()
|
||||
.null(),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
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> {
|
||||
if !manager
|
||||
.has_column("site_settings", "paragraph_comments_enabled")
|
||||
.await?
|
||||
{
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(Alias::new("site_settings"))
|
||||
.add_column(
|
||||
ColumnDef::new(Alias::new("paragraph_comments_enabled"))
|
||||
.boolean()
|
||||
.null()
|
||||
.default(true),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
if manager
|
||||
.has_column("site_settings", "paragraph_comments_enabled")
|
||||
.await?
|
||||
{
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(Alias::new("site_settings"))
|
||||
.drop_column(Alias::new("paragraph_comments_enabled"))
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
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 posts_table = Alias::new("posts");
|
||||
let site_settings_table = Alias::new("site_settings");
|
||||
|
||||
if !manager.has_column("posts", "images").await? {
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(posts_table.clone())
|
||||
.add_column(ColumnDef::new(Alias::new("images")).json_binary().null())
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
if !manager
|
||||
.has_column("site_settings", "music_playlist")
|
||||
.await?
|
||||
{
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(site_settings_table.clone())
|
||||
.add_column(
|
||||
ColumnDef::new(Alias::new("music_playlist"))
|
||||
.json_binary()
|
||||
.null(),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
let posts_table = Alias::new("posts");
|
||||
let site_settings_table = Alias::new("site_settings");
|
||||
|
||||
if manager.has_column("posts", "images").await? {
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(posts_table)
|
||||
.drop_column(Alias::new("images"))
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
if manager
|
||||
.has_column("site_settings", "music_playlist")
|
||||
.await?
|
||||
{
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(site_settings_table)
|
||||
.drop_column(Alias::new("music_playlist"))
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
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> {
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(Reviews::Table)
|
||||
.add_column(ColumnDef::new(Reviews::LinkUrl).string().null())
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(Reviews::Table)
|
||||
.drop_column(Reviews::LinkUrl)
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(DeriveIden)]
|
||||
enum Reviews {
|
||||
Table,
|
||||
LinkUrl,
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
use sea_orm::{DbBackend, Statement};
|
||||
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 table = Alias::new("site_settings");
|
||||
|
||||
if !manager.has_column("site_settings", "ai_providers").await? {
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(table.clone())
|
||||
.add_column(
|
||||
ColumnDef::new(Alias::new("ai_providers"))
|
||||
.json_binary()
|
||||
.null(),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
if !manager
|
||||
.has_column("site_settings", "ai_active_provider_id")
|
||||
.await?
|
||||
{
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(table)
|
||||
.add_column(
|
||||
ColumnDef::new(Alias::new("ai_active_provider_id"))
|
||||
.string()
|
||||
.null(),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
manager
|
||||
.get_connection()
|
||||
.execute(Statement::from_string(
|
||||
DbBackend::Postgres,
|
||||
r#"
|
||||
UPDATE site_settings
|
||||
SET
|
||||
ai_providers = jsonb_build_array(
|
||||
jsonb_strip_nulls(
|
||||
jsonb_build_object(
|
||||
'id', 'default',
|
||||
'name', COALESCE(NULLIF(trim(ai_provider), ''), '默认提供商'),
|
||||
'provider', COALESCE(NULLIF(trim(ai_provider), ''), 'newapi'),
|
||||
'api_base', NULLIF(trim(ai_api_base), ''),
|
||||
'api_key', NULLIF(trim(ai_api_key), ''),
|
||||
'chat_model', NULLIF(trim(ai_chat_model), '')
|
||||
)
|
||||
)
|
||||
),
|
||||
ai_active_provider_id = COALESCE(NULLIF(trim(ai_active_provider_id), ''), 'default')
|
||||
WHERE ai_providers IS NULL
|
||||
AND (
|
||||
COALESCE(trim(ai_provider), '') <> ''
|
||||
OR COALESCE(trim(ai_api_base), '') <> ''
|
||||
OR COALESCE(trim(ai_api_key), '') <> ''
|
||||
OR COALESCE(trim(ai_chat_model), '') <> ''
|
||||
)
|
||||
"#
|
||||
.to_string(),
|
||||
))
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
let table = Alias::new("site_settings");
|
||||
|
||||
for column in ["ai_active_provider_id", "ai_providers"] {
|
||||
if manager.has_column("site_settings", column).await? {
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(table.clone())
|
||||
.drop_column(Alias::new(column))
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user