Update: 2026-05-06 01:43:59
This commit is contained in:
@@ -22,13 +22,23 @@ echo " مُصادَق — Phase 3 Migration\n";
|
|||||||
echo " Mobile App + Batch Processing Support\n";
|
echo " Mobile App + Batch Processing Support\n";
|
||||||
echo "═══════════════════════════════════════════\n\n";
|
echo "═══════════════════════════════════════════\n\n";
|
||||||
|
|
||||||
|
// --- Fetch Parent Collation dynamically ---
|
||||||
|
$stmt = $db->query("SHOW FULL COLUMNS FROM users WHERE Field = 'id'");
|
||||||
|
$userCol = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
$charsetCollation = "";
|
||||||
|
if ($userCol && !empty($userCol['Collation'])) {
|
||||||
|
$collation = $userCol['Collation'];
|
||||||
|
list($charset) = explode('_', $collation);
|
||||||
|
$charsetCollation = "CHARACTER SET {$charset} COLLATE {$collation}";
|
||||||
|
}
|
||||||
|
|
||||||
$migrations = [
|
$migrations = [
|
||||||
|
|
||||||
// ─── 1. User Device Management ─────────────────────────
|
// ─── 1. User Device Management ─────────────────────────
|
||||||
'create_user_devices' => "
|
'create_user_devices' => "
|
||||||
CREATE TABLE IF NOT EXISTS user_devices (
|
CREATE TABLE IF NOT EXISTS user_devices (
|
||||||
id CHAR(36) PRIMARY KEY DEFAULT (UUID()),
|
id CHAR(36) {$charsetCollation} PRIMARY KEY DEFAULT (UUID()),
|
||||||
user_id CHAR(36) NOT NULL,
|
user_id CHAR(36) {$charsetCollation} NOT NULL,
|
||||||
device_fingerprint VARCHAR(64) NOT NULL,
|
device_fingerprint VARCHAR(64) NOT NULL,
|
||||||
device_name VARCHAR(100) NULL,
|
device_name VARCHAR(100) NULL,
|
||||||
platform ENUM('android','ios','web') NOT NULL DEFAULT 'android',
|
platform ENUM('android','ios','web') NOT NULL DEFAULT 'android',
|
||||||
@@ -55,10 +65,10 @@ $migrations = [
|
|||||||
// ─── 3. Invoice Batches (Mobile Scanner) ───────────────
|
// ─── 3. Invoice Batches (Mobile Scanner) ───────────────
|
||||||
'create_invoice_batches' => "
|
'create_invoice_batches' => "
|
||||||
CREATE TABLE IF NOT EXISTS invoice_batches (
|
CREATE TABLE IF NOT EXISTS invoice_batches (
|
||||||
id CHAR(36) PRIMARY KEY,
|
id CHAR(36) {$charsetCollation} PRIMARY KEY,
|
||||||
tenant_id CHAR(36) NOT NULL,
|
tenant_id CHAR(36) {$charsetCollation} NOT NULL,
|
||||||
company_id CHAR(36) NOT NULL,
|
company_id CHAR(36) {$charsetCollation} NOT NULL,
|
||||||
uploaded_by CHAR(36) NOT NULL,
|
uploaded_by CHAR(36) {$charsetCollation} NOT NULL,
|
||||||
total_images INT NOT NULL DEFAULT 0,
|
total_images INT NOT NULL DEFAULT 0,
|
||||||
processed_images INT NOT NULL DEFAULT 0,
|
processed_images INT NOT NULL DEFAULT 0,
|
||||||
failed_images INT NOT NULL DEFAULT 0,
|
failed_images INT NOT NULL DEFAULT 0,
|
||||||
@@ -81,10 +91,10 @@ $migrations = [
|
|||||||
'create_processing_queue' => "
|
'create_processing_queue' => "
|
||||||
CREATE TABLE IF NOT EXISTS invoice_processing_queue (
|
CREATE TABLE IF NOT EXISTS invoice_processing_queue (
|
||||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
batch_id CHAR(36) NOT NULL,
|
batch_id CHAR(36) {$charsetCollation} NOT NULL,
|
||||||
invoice_id CHAR(36) NULL,
|
invoice_id CHAR(36) {$charsetCollation} NULL,
|
||||||
tenant_id CHAR(36) NOT NULL,
|
tenant_id CHAR(36) {$charsetCollation} NOT NULL,
|
||||||
company_id CHAR(36) NOT NULL,
|
company_id CHAR(36) {$charsetCollation} NOT NULL,
|
||||||
image_path VARCHAR(500) NOT NULL,
|
image_path VARCHAR(500) NOT NULL,
|
||||||
image_order INT NOT NULL DEFAULT 0,
|
image_order INT NOT NULL DEFAULT 0,
|
||||||
status ENUM('pending','processing','done','failed') DEFAULT 'pending',
|
status ENUM('pending','processing','done','failed') DEFAULT 'pending',
|
||||||
@@ -106,9 +116,9 @@ $migrations = [
|
|||||||
// ─── 6. Notifications Table ────────────────────────────
|
// ─── 6. Notifications Table ────────────────────────────
|
||||||
'create_notifications' => "
|
'create_notifications' => "
|
||||||
CREATE TABLE IF NOT EXISTS notifications (
|
CREATE TABLE IF NOT EXISTS notifications (
|
||||||
id CHAR(36) PRIMARY KEY DEFAULT (UUID()),
|
id CHAR(36) {$charsetCollation} PRIMARY KEY DEFAULT (UUID()),
|
||||||
tenant_id CHAR(36) NOT NULL,
|
tenant_id CHAR(36) {$charsetCollation} NOT NULL,
|
||||||
user_id CHAR(36) NULL,
|
user_id CHAR(36) {$charsetCollation} NULL,
|
||||||
type VARCHAR(50) NOT NULL,
|
type VARCHAR(50) NOT NULL,
|
||||||
title VARCHAR(255) NOT NULL,
|
title VARCHAR(255) NOT NULL,
|
||||||
body TEXT NULL,
|
body TEXT NULL,
|
||||||
|
|||||||
Reference in New Issue
Block a user