25 lines
1.4 KiB
PowerShell
25 lines
1.4 KiB
PowerShell
|
|
$root = Split-Path -Parent $PSScriptRoot
|
|||
|
|
# Полный дамп после распаковки zip кладите в data/dumps/
|
|||
|
|
$src = Join-Path $root 'data\dumps\date-db-mysql_meraproject_2026.05.13_14-00-06.sql'
|
|||
|
|
$dst = Join-Path $root 'data\mysql-init\01-j7508239_tracker.sql'
|
|||
|
|
if (-not (Test-Path -LiteralPath $src)) {
|
|||
|
|
Write-Error "Source dump not found: $src"
|
|||
|
|
exit 1
|
|||
|
|
}
|
|||
|
|
# Строка 1068 файла дампа — начало секции прикладной БД (после системной `mysql`)
|
|||
|
|
$lines = Get-Content -LiteralPath $src -Encoding UTF8
|
|||
|
|
$from = 1066 # 0-based: с комментария "-- Current Database: `j7508239_tracker`"
|
|||
|
|
$slice = $lines[$from..($lines.Length - 1)]
|
|||
|
|
# TEXT (~64KB) мало для msPortalSection.data (JSON + HTML) — иначе init: ERROR 1406 Data too long … row 2
|
|||
|
|
$text = [string]::Join("`n", $slice)
|
|||
|
|
# В replacement для .NET: $1 = группа (в одинарных кавычках PowerShell не подставляет переменные)
|
|||
|
|
$text = [regex]::Replace(
|
|||
|
|
$text,
|
|||
|
|
'`msPortalSection_data`\s+text(\s+COLLATE)',
|
|||
|
|
'`msPortalSection_data` mediumtext$1',
|
|||
|
|
[System.Text.RegularExpressions.RegexOptions]::IgnoreCase
|
|||
|
|
)
|
|||
|
|
$utf8 = New-Object System.Text.UTF8Encoding $false
|
|||
|
|
[System.IO.File]::WriteAllText($dst, $text, $utf8)
|
|||
|
|
Write-Host "Written $($slice.Count) lines to $dst ($((Get-Item $dst).Length) bytes) [msPortalSection_data to mediumtext]"
|