meraproject/scripts/extract-tracker-db.ps1
keboss-m 5c21d25d45 Initial commit: Merakomis portal, Docker stack and user-reader API.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-24 11:04:05 +03:00

25 lines
1.4 KiB
PowerShell
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

$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]"