Git Komut Rehberi & Terminal Asistanı
Sıfırdan Yeni Bir Depo Başlatın:
Mevcut Bir Git Deposu veya Klasörü Gönderin:
Hataları Geri Alma, İptal & Temizlik:
Son commit'i geri al (yapılan değişiklikleri korur):
git reset --soft HEAD~1
Yapılan yerel değişiklikleri iptal et (çalışma ağacını temizler):
git restore .
Takip edilmeyen gereksiz dosyaları sil:
git clean -fd
Değişiklikleri geçici sakla ve geri getir (stash):
git stash git stash pop
Dal (Branch) ve Sürüm Etiketleri:
Yeni dal aç ve geçiş yap:
git checkout -b yeni-ozellik git push -u origin yeni-ozellik
Sürüm etiketi (tag) oluştur ve gönder:
git tag -a v1.0.0 -m "Sürüm 1.0.0" git push origin --tags
Build and Push Docker Images / build (push) Canceled after 0s
Desktop Release / Build linux desktop (push) Canceled after 0s
Desktop Release / Build windows desktop (push) Canceled after 0s
Desktop Release / Attach packages to release (push) Canceled after 0s
Desktop Release / Build macos desktop (push) Canceled after 0s
CI / Typecheck and unit tests (push) Canceled after 0s
159 lines
8.3 KiB
PHP
159 lines
8.3 KiB
PHP
<?php
|
||
/**
|
||
* SnapCAD veritabanı şeması.
|
||
*
|
||
* Bu dosya yalnızca CLI migrasyon betiği (database/migrate.php) veya
|
||
* SNAPCAD_AUTO_MIGRATE=true verildiğinde çalıştırılır. Normal HTTP isteklerinde
|
||
* DDL çalıştırılmaz.
|
||
*/
|
||
|
||
if (!function_exists('snapcad_apply_schema')) {
|
||
/**
|
||
* SnapCAD tablolarını ve eksik sütunları idempotent biçimde hazırlar.
|
||
*/
|
||
function snapcad_apply_schema(PDO $pdo): void
|
||
{
|
||
$pdo->exec("
|
||
CREATE TABLE IF NOT EXISTS snapcad_cloud_projects (
|
||
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||
project_uid VARCHAR(64) NOT NULL,
|
||
user_id BIGINT UNSIGNED NOT NULL,
|
||
user_email VARCHAR(255) DEFAULT NULL,
|
||
user_name VARCHAR(255) DEFAULT NULL,
|
||
title VARCHAR(255) NOT NULL DEFAULT 'Adsız Tasarım',
|
||
category VARCHAR(120) DEFAULT 'Genel 3B Tasarım',
|
||
shapes_count INT NOT NULL DEFAULT 0,
|
||
project_json LONGTEXT NOT NULL,
|
||
is_public TINYINT(1) NOT NULL DEFAULT 0,
|
||
share_code VARCHAR(64) DEFAULT NULL,
|
||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||
UNIQUE KEY uq_user_project (user_id, project_uid),
|
||
INDEX idx_user_updated (user_id, updated_at),
|
||
INDEX idx_share_code (share_code)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||
|
||
CREATE TABLE IF NOT EXISTS snapcad_classrooms (
|
||
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||
class_code VARCHAR(16) NOT NULL,
|
||
teacher_user_id BIGINT UNSIGNED NOT NULL,
|
||
teacher_name VARCHAR(255) NOT NULL,
|
||
teacher_email VARCHAR(255) DEFAULT NULL,
|
||
title VARCHAR(255) NOT NULL,
|
||
description TEXT DEFAULT NULL,
|
||
grade_level VARCHAR(64) DEFAULT 'Ortaokul / Lise',
|
||
subject VARCHAR(64) DEFAULT '3D CAD & Devreler',
|
||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||
UNIQUE KEY uq_class_code (class_code),
|
||
INDEX idx_teacher (teacher_user_id)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||
|
||
CREATE TABLE IF NOT EXISTS snapcad_classroom_members (
|
||
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||
classroom_id BIGINT UNSIGNED NOT NULL,
|
||
user_id BIGINT UNSIGNED DEFAULT NULL,
|
||
display_name VARCHAR(255) NOT NULL,
|
||
nickname VARCHAR(64) NOT NULL,
|
||
pin_hash VARCHAR(255) DEFAULT NULL,
|
||
avatar VARCHAR(255) DEFAULT NULL,
|
||
role VARCHAR(32) DEFAULT 'student',
|
||
joined_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||
UNIQUE KEY uq_class_nick (classroom_id, nickname),
|
||
INDEX idx_class_user (classroom_id, user_id),
|
||
INDEX idx_user_class (user_id)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||
|
||
CREATE TABLE IF NOT EXISTS snapcad_classroom_activities (
|
||
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||
classroom_id BIGINT UNSIGNED NOT NULL,
|
||
title VARCHAR(255) NOT NULL,
|
||
instructions TEXT DEFAULT NULL,
|
||
starter_project_json LONGTEXT DEFAULT NULL,
|
||
studio_type VARCHAR(32) DEFAULT '3d-solid',
|
||
due_date VARCHAR(64) DEFAULT NULL,
|
||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||
INDEX idx_activity_class (classroom_id)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||
|
||
CREATE TABLE IF NOT EXISTS snapcad_classroom_projects (
|
||
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||
classroom_id BIGINT UNSIGNED NOT NULL,
|
||
member_id BIGINT UNSIGNED NOT NULL,
|
||
activity_id BIGINT UNSIGNED DEFAULT NULL,
|
||
project_uid VARCHAR(64) NOT NULL,
|
||
title VARCHAR(255) NOT NULL DEFAULT 'Öğrenci Tasarımı',
|
||
studio_type VARCHAR(32) DEFAULT '3d-solid',
|
||
shapes_count INT NOT NULL DEFAULT 0,
|
||
project_json LONGTEXT NOT NULL,
|
||
thumbnail_data_url MEDIUMTEXT DEFAULT NULL,
|
||
teacher_feedback TEXT DEFAULT NULL,
|
||
teacher_grade VARCHAR(16) DEFAULT NULL,
|
||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||
UNIQUE KEY uq_class_member_proj (classroom_id, member_id, project_uid),
|
||
INDEX idx_class_updated (classroom_id, updated_at)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||
|
||
CREATE TABLE IF NOT EXISTS snapcad_rate_limits (
|
||
bucket_key VARCHAR(191) NOT NULL PRIMARY KEY,
|
||
hits INT UNSIGNED NOT NULL DEFAULT 0,
|
||
window_start DATETIME NOT NULL,
|
||
INDEX idx_rate_window (window_start)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||
|
||
CREATE TABLE IF NOT EXISTS snapcad_shared_components (
|
||
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||
component_uid VARCHAR(64) NOT NULL,
|
||
user_id BIGINT UNSIGNED NOT NULL,
|
||
author_name VARCHAR(255) NOT NULL DEFAULT 'YakNet Kullanıcısı',
|
||
title VARCHAR(255) NOT NULL DEFAULT 'Adsız Bileşen',
|
||
category VARCHAR(120) NOT NULL DEFAULT 'Genel 3B Bileşen',
|
||
description TEXT DEFAULT NULL,
|
||
shapes_json LONGTEXT NOT NULL,
|
||
shapes_count INT NOT NULL DEFAULT 1,
|
||
is_public TINYINT(1) NOT NULL DEFAULT 1,
|
||
downloads_count INT UNSIGNED NOT NULL DEFAULT 0,
|
||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||
UNIQUE KEY uq_component_uid (component_uid),
|
||
INDEX idx_comp_public_updated (is_public, updated_at),
|
||
INDEX idx_comp_user (user_id, updated_at)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||
|
||
CREATE TABLE IF NOT EXISTS snapcad_user_prefs (
|
||
user_id BIGINT UNSIGNED NOT NULL PRIMARY KEY,
|
||
prefs_json MEDIUMTEXT NOT NULL,
|
||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||
|
||
CREATE TABLE IF NOT EXISTS snapcad_desktop_tokens (
|
||
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||
user_id BIGINT UNSIGNED NOT NULL,
|
||
user_name VARCHAR(255) NOT NULL,
|
||
user_email VARCHAR(255) DEFAULT NULL,
|
||
user_avatar VARCHAR(512) DEFAULT NULL,
|
||
token_hash CHAR(64) DEFAULT NULL,
|
||
exchange_code_hash CHAR(64) DEFAULT NULL,
|
||
nonce_hash CHAR(64) DEFAULT NULL,
|
||
device_label VARCHAR(120) DEFAULT 'SnapCAD Masaüstü',
|
||
exchange_expires_at DATETIME DEFAULT NULL,
|
||
expires_at DATETIME NOT NULL,
|
||
last_used_at DATETIME DEFAULT NULL,
|
||
revoked_at DATETIME DEFAULT NULL,
|
||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||
UNIQUE KEY uq_token_hash (token_hash),
|
||
UNIQUE KEY uq_exchange_code_hash (exchange_code_hash),
|
||
INDEX idx_user_revoked (user_id, revoked_at),
|
||
INDEX idx_expires_at (expires_at)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||
");
|
||
|
||
// Geriye dönük şema güncellemeleri. Sütun varsa DDL çalıştırılmaz.
|
||
$pinColumn = $pdo->query("SHOW COLUMNS FROM snapcad_classroom_members LIKE 'pin_hash'")->fetch();
|
||
if (!$pinColumn) {
|
||
$pdo->exec("ALTER TABLE snapcad_classroom_members ADD COLUMN pin_hash VARCHAR(255) DEFAULT NULL AFTER nickname");
|
||
}
|
||
}
|
||
}
|