gitea init

This commit is contained in:
skryper
2025-10-08 21:28:30 +04:00
commit d4651a423d
2518 changed files with 522832 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
# Update directory security
RewriteEngine On
# Deny access to backup files
<Files "*.sql">
Require all denied
</Files>
# Deny access to migration files from web
<FilesMatch "\.(php)$">
<RequireAll>
Require all denied
Require local
</RequireAll>
</FilesMatch>
# Allow only index.php
<Files "index.php">
Require all granted
</Files>
# Deny access to sensitive directories
RedirectMatch 404 /admin/update/backups/
RedirectMatch 404 /admin/update/migrations/
+163
View File
@@ -0,0 +1,163 @@
# განახლებების მართვის სისტემა
## 📁 სტრუქტურა
```
/admin/update/
├── index.php # ვებ ინტერფეისი
├── UpdateManager.php # მთავარი კლასი
├── update_cli.php # CLI ინტერფეისი
├── README.md # ეს ფაილი
├── migrations/ # მიგრაციის ფაილები
│ ├── 1.0.1_add_phone_column_to_users_table.php
│ └── 1.0.2_add_settings_table.php
├── versions/ # ვერსიების ინფორმაცია
└── backups/ # ავტომატური backup-ები
```
## 🌐 ვებ ინტერფეისი
ვებ ინტერფეისის გამოყენება: `/admin/update/`
### ფუნქციები:
- ✅ ხელმისაწვდომი განახლებების ჩვენება
- ✅ განახლებების გაშვება (ცალ-ცალკე ან ყველა ერთად)
- ✅ განახლებების ისტორია
- ✅ ახალი მიგრაციის შექმნა
- ✅ ავტომატური backup-ების შექმნა
## 💻 CLI ინტერფეისი
### ძირითადი ბრძანებები:
```bash
# სისტემის სტატუსი
php update_cli.php status
# ხელმისაწვდომი განახლებების სია
php update_cli.php list
# ყველა განახლების გაშვება
php update_cli.php update
# კონკრეტული ვერსიის განახლება
php update_cli.php update 1.0.1
# განახლებების ისტორია
php update_cli.php history
# ახალი მიგრაციის შექმნა
php update_cli.php create 1.0.3 "Add new feature" "ALTER TABLE users ADD COLUMN status VARCHAR(20)"
```
## 📝 მიგრაციის ფაილის ფორმატი
მიგრაციის ფაილები უნდა იყოს `migrations/` დირექტორიაში:
**ფაილის სახელი:** `{version}_{description}.php`
**მაგალითი:** `1.0.1_add_phone_column_to_users_table.php`
```php
<?php
/**
* Migration: Add phone column to users table
* Version: 1.0.1
* Created: 2025-07-31 09:30:00
*/
try {
// განახლების SQL
$upSql = "ALTER TABLE users ADD COLUMN phone VARCHAR(20) DEFAULT NULL AFTER email";
if ($upSql) {
$pdo->exec($upSql);
echo "✅ Add phone column to users table - წარმატებით შესრულდა\n";
}
} catch (Exception $e) {
// Rollback SQL (არასავალდებულო)
$downSql = "ALTER TABLE users DROP COLUMN phone";
if ($downSql) {
try {
$pdo->exec($downSql);
echo "⚠️ Rollback SQL შესრულდა\n";
} catch (Exception $rollbackError) {
echo "❌ Rollback შეცდომა: " . $rollbackError->getMessage() . "\n";
}
}
throw new Exception("Add phone column to users table - შეცდომა: " . $e->getMessage());
}
?>
```
## 🗄️ ბაზის ცხრილი
სისტემა ქმნის `version_history` ცხრილს:
```sql
CREATE TABLE version_history (
id INT AUTO_INCREMENT PRIMARY KEY,
version VARCHAR(20) NOT NULL,
description TEXT,
migration_file VARCHAR(255),
executed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
status ENUM('pending', 'completed', 'failed') DEFAULT 'pending'
);
```
## 🔒 უსაფრთხოება
- ✅ ყოველი განახლების წინ ავტომატური database backup
- ✅ კონფიგურაციის ფაილის backup
- ✅ Rollback მხარდაჭერა
- ✅ განახლებების ვერსიების თანმიმდევრულობა
- ✅ ავტორიზაციის შემოწმება
## 📋 ვერსიების ნუმერაცია
სემანტიკური ვერსიონინგი: `MAJOR.MINOR.PATCH`
- **MAJOR**: არათავსებადი ცვლილებები
- **MINOR**: ახალი ფუნქციონალი (უკუთავსებადი)
- **PATCH**: bug fixes
## 🚨 მნიშვნელოვანი!
1. **Backup**: ყოველი განახლების წინ ავტომატურად იქმნება backup
2. **Testing**: მიგრაციები ჯერ test ბაზაზე უნდა გატესტდეს
3. **Rollback**: თუ შეცდომა მოხდა, rollback SQL ავტომატურად შესრულდება
4. **Permissions**: update/ დირექტორია უნდა იყოს writable
## 🔧 გამოყენების მაგალითები
### ახალი column-ის დამატება users ცხრილში:
```bash
php update_cli.php create 1.0.3 "Add phone field" "ALTER TABLE users ADD COLUMN phone VARCHAR(20)" "ALTER TABLE users DROP COLUMN phone"
```
### ახალი ცხრილის შექმნა:
```bash
php update_cli.php create 1.1.0 "Add logs table" "CREATE TABLE logs (id INT AUTO_INCREMENT PRIMARY KEY, message TEXT, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)" "DROP TABLE logs"
```
### მონაცემების განახლება:
```bash
php update_cli.php create 1.0.4 "Update user statuses" "UPDATE users SET status = 'active' WHERE status IS NULL"
```
## 📞 მხარდაჭერა
თუ რაიმე პრობლემა მოხდა:
1. შეამოწმეთ PHP error logs
2. გადახედეთ backups/ დირექტორიას
3. გამოიყენეთ rollback SQL მაშინ თუ საჭიროა
4. კონსულტაცია დეველოპერთან
---
+261
View File
@@ -0,0 +1,261 @@
<?php
/**
* Update Manager - განახლებების მართვის სისტემა
* ვერსია: 1.0.0
*/
class UpdateManager {
private $pdo;
private $currentVersion;
private $updatePath;
private $backupPath;
public function __construct($pdo = null)
{
if ($pdo === null) {
// თუ PDO არ არის გადაცემული, ვიყენებთ მიგრაციის db ფაილს
require_once __DIR__ . '/includes/db_migration.php';
global $pdo;
}
$this->pdo = $pdo;
$this->initVersionTable();
}
/**
* ვერსიების ცხრილის ინიციალიზაცია
*/
private function initVersionTable() {
$sql = "CREATE TABLE IF NOT EXISTS version_history (
id INT AUTO_INCREMENT PRIMARY KEY,
version VARCHAR(20) NOT NULL,
description TEXT,
migration_file VARCHAR(255),
executed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
status ENUM('pending', 'completed', 'failed') DEFAULT 'pending'
)";
$this->pdo->exec($sql);
}
/**
* მიმდინარე ვერსიის მიღება
*/
public function getCurrentVersion() {
try {
$stmt = $this->pdo->query("SELECT version FROM version_history WHERE status = 'completed' ORDER BY executed_at DESC LIMIT 1");
$result = $stmt->fetch();
return $result ? $result['version'] : '1.0.0';
} catch (Exception $e) {
return '1.0.0';
}
}
/**
* ხელმისაწვდომი განახლებების სია
*/
public function getAvailableUpdates() {
$migrations = glob($this->updatePath . '/migrations/*.php');
$available = [];
foreach ($migrations as $file) {
$filename = basename($file);
if (preg_match('/^(\d+\.\d+\.\d+)_(.+)\.php$/', $filename, $matches)) {
$version = $matches[1];
$description = str_replace('_', ' ', $matches[2]);
// შევამოწმოთ უკვე გაშვებულია თუ არა
$stmt = $this->pdo->prepare("SELECT id FROM version_history WHERE version = ? AND status = 'completed'");
$stmt->execute([$version]);
if (!$stmt->fetch()) {
$available[] = [
'version' => $version,
'description' => $description,
'file' => $file,
'filename' => $filename
];
}
}
}
// ვერსიის მიხედვით დალაგება
usort($available, function($a, $b) {
return version_compare($a['version'], $b['version']);
});
return $available;
}
/**
* განახლების გაშვება
*/
public function runUpdate($version) {
$updates = $this->getAvailableUpdates();
$updateToRun = null;
foreach ($updates as $update) {
if ($update['version'] === $version) {
$updateToRun = $update;
break;
}
}
if (!$updateToRun) {
throw new Exception("განახლება ვერსია $version ვერ მოიძებნა");
}
// backup-ის შექმნა
$this->createBackup($version);
// განახლების ჩანაწერი
$stmt = $this->pdo->prepare("INSERT INTO version_history (version, description, migration_file, status) VALUES (?, ?, ?, 'pending')");
$stmt->execute([$version, $updateToRun['description'], $updateToRun['filename']]);
$updateId = $this->pdo->lastInsertId();
try {
// მიგრაციის ფაილის ჩატვირთვა და გაშვება
require_once $updateToRun['file'];
// განახლების სტატუსის შეცვლა
$stmt = $this->pdo->prepare("UPDATE version_history SET status = 'completed' WHERE id = ?");
$stmt->execute([$updateId]);
return [
'success' => true,
'message' => "განახლება $version წარმატებით დასრულდა",
'version' => $version
];
} catch (Exception $e) {
// შეცდომის მტკიცების ჩანაწერი
$stmt = $this->pdo->prepare("UPDATE version_history SET status = 'failed' WHERE id = ?");
$stmt->execute([$updateId]);
throw new Exception("განახლების შეცდომა: " . $e->getMessage());
}
}
/**
* ყველა ხელმისაწვდომი განახლების გაშვება
*/
public function runAllUpdates() {
$updates = $this->getAvailableUpdates();
$results = [];
foreach ($updates as $update) {
try {
$result = $this->runUpdate($update['version']);
$results[] = $result;
} catch (Exception $e) {
$results[] = [
'success' => false,
'message' => $e->getMessage(),
'version' => $update['version']
];
break; // შეწყვიტოს შემდგომი განახლებები შეცდომის შემთხვევაში
}
}
return $results;
}
/**
* Backup-ის შექმნა
*/
private function createBackup($version) {
$backupDir = $this->backupPath . '/backup_' . $version . '_' . date('Y-m-d_H-i-s');
if (!is_dir($backupDir)) {
mkdir($backupDir, 0755, true);
}
// ბაზის backup
$config = include __DIR__ . '/../config.php';
$dumpFile = $backupDir . '/database_backup.sql';
$command = sprintf(
'mysqldump -h%s -u%s -p%s %s > %s',
escapeshellarg($config['host']),
escapeshellarg($config['user']),
escapeshellarg($config['pass']),
escapeshellarg($config['dbname']),
escapeshellarg($dumpFile)
);
exec($command, $output, $returnVar);
if ($returnVar !== 0) {
throw new Exception("ბაზის backup ვერ შეიქმნა");
}
// კონფიგურაციის ფაილის backup
copy(__DIR__ . '/../config.php', $backupDir . '/config_backup.php');
return $backupDir;
}
/**
* განახლებების ისტორია
*/
public function getUpdateHistory() {
$stmt = $this->pdo->query("SELECT * FROM version_history ORDER BY executed_at DESC");
return $stmt->fetchAll();
}
/**
* ახალი მიგრაციის ფაილის შექმნა
*/
public function createMigration($version, $description, $upSql, $downSql = '') {
$filename = $version . '_' . str_replace(' ', '_', strtolower($description)) . '.php';
$filepath = $this->updatePath . '/migrations/' . $filename;
$template = $this->getMigrationTemplate($version, $description, $upSql, $downSql);
if (file_put_contents($filepath, $template)) {
return [
'success' => true,
'message' => "მიგრაციის ფაილი შეიქმნა: $filename",
'file' => $filepath
];
} else {
throw new Exception("მიგრაციის ფაილის შექმნა ვერ მოხერხდა");
}
}
/**
* მიგრაციის ფაილის შაბლონი
*/
private function getMigrationTemplate($version, $description, $upSql, $downSql) {
return "<?php
/**
* Migration: $description
* Version: $version
* Created: " . date('Y-m-d H:i:s') . "
*/
try {
// განახლების SQL
\$upSql = \"$upSql\";
if (\$upSql) {
\$pdo->exec(\$upSql);
echo \"$description - წარმატებით შესრულდა\\n\";
}
} catch (Exception \$e) {
// Rollback SQL (არასავალდებულო)
\$downSql = \"$downSql\";
if (\$downSql) {
try {
\$pdo->exec(\$downSql);
echo \"⚠️ Rollback SQL შესრულდა\\n\";
} catch (Exception \$rollbackError) {
echo \"❌ Rollback შეცდომა: \" . \$rollbackError->getMessage() . \"\\n\";
}
}
throw new Exception(\"$description - შეცდომა: \" . \$e->getMessage());
}
?>";
}
}
?>
@@ -0,0 +1,25 @@
<?php
return array (
'host' => 'localhost',
'user' => 'user',
'pass' => 'password',
'dbname' => 'mydb',
'port' => 3306,
'charset' => 'utf8mb4',
'db' =>
array (
'host' => 'localhost',
'user' => 'user',
'pass' => 'password',
'name' => 'mydb',
'port' => 3306,
'charset' => 'utf8mb4',
),
'app' =>
array (
'base_url' => 'http://localhost/',
'debug' => true,
'installed' => true,
'version' => '1.0.0',
),
);
@@ -0,0 +1,338 @@
/*M!999999\- enable the sandbox mode */
-- MariaDB dump 10.19 Distrib 10.11.11-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: localhost Database: mydb
-- ------------------------------------------------------
-- Server version 10.11.11-MariaDB-0+deb12u1
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `clients`
--
DROP TABLE IF EXISTS `clients`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `clients` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`first_name` varchar(100) NOT NULL,
`last_name` varchar(100) NOT NULL,
`company_name` varchar(150) DEFAULT NULL,
`vat_number` varchar(150) DEFAULT NULL,
`email` varchar(150) NOT NULL,
`password` varchar(255) NOT NULL,
`address1` varchar(255) DEFAULT NULL,
`address2` varchar(255) DEFAULT NULL,
`city` varchar(100) DEFAULT NULL,
`state` varchar(100) DEFAULT NULL,
`postcode` varchar(20) DEFAULT NULL,
`country` varchar(2) DEFAULT NULL,
`phone` varchar(50) DEFAULT NULL,
`payment_method` varchar(50) DEFAULT NULL,
`billing_contact` varchar(100) DEFAULT NULL,
`currency` varchar(10) DEFAULT 'USD',
`language` varchar(10) DEFAULT 'default',
`status` enum('active','inactive') DEFAULT 'active',
`client_group` varchar(50) DEFAULT 'none',
`created_at` timestamp NULL DEFAULT current_timestamp(),
`admin_notes` text DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `clients`
--
LOCK TABLES `clients` WRITE;
/*!40000 ALTER TABLE `clients` DISABLE KEYS */;
/*!40000 ALTER TABLE `clients` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `email_logs`
--
DROP TABLE IF EXISTS `email_logs`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `email_logs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`client_id` int(11) NOT NULL,
`subject` varchar(255) DEFAULT NULL,
`message` text DEFAULT NULL,
`sent_at` datetime DEFAULT current_timestamp(),
PRIMARY KEY (`id`),
KEY `client_id` (`client_id`),
CONSTRAINT `email_logs_ibfk_1` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `email_logs`
--
LOCK TABLES `email_logs` WRITE;
/*!40000 ALTER TABLE `email_logs` DISABLE KEYS */;
/*!40000 ALTER TABLE `email_logs` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `email_templates`
--
DROP TABLE IF EXISTS `email_templates`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `email_templates` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`subject` varchar(255) NOT NULL,
`body` text NOT NULL,
`created_at` datetime DEFAULT current_timestamp(),
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `email_templates`
--
LOCK TABLES `email_templates` WRITE;
/*!40000 ALTER TABLE `email_templates` DISABLE KEYS */;
/*!40000 ALTER TABLE `email_templates` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `invoice_items`
--
DROP TABLE IF EXISTS `invoice_items`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `invoice_items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`invoice_id` int(11) NOT NULL,
`product_id` int(11) DEFAULT NULL,
`description` text DEFAULT NULL,
`amount` decimal(10,2) NOT NULL DEFAULT 0.00,
PRIMARY KEY (`id`),
KEY `invoice_id` (`invoice_id`),
CONSTRAINT `invoice_items_ibfk_1` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `invoice_items`
--
LOCK TABLES `invoice_items` WRITE;
/*!40000 ALTER TABLE `invoice_items` DISABLE KEYS */;
/*!40000 ALTER TABLE `invoice_items` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `invoices`
--
DROP TABLE IF EXISTS `invoices`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `invoices` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`invoice_number` varchar(100) DEFAULT NULL,
`client_id` int(11) NOT NULL,
`description` text DEFAULT NULL,
`payment_method` varchar(100) DEFAULT NULL,
`status` enum('დრაფტი','გადაუხდელი','გადასახდელი','გადახდილი','გაუქმებული') NOT NULL DEFAULT 'დრაფტი',
`total_amount` decimal(10,2) NOT NULL DEFAULT 0.00,
`is_recurring` tinyint(1) DEFAULT 0,
`issue_date` date NOT NULL,
`due_date` date NOT NULL,
`payment_date` date DEFAULT NULL,
`created_at` timestamp NULL DEFAULT current_timestamp(),
`recurring` tinyint(1) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `invoice_number` (`invoice_number`),
KEY `client_id` (`client_id`),
CONSTRAINT `invoices_ibfk_1` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `invoices`
--
LOCK TABLES `invoices` WRITE;
/*!40000 ALTER TABLE `invoices` DISABLE KEYS */;
/*!40000 ALTER TABLE `invoices` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `migration_log`
--
DROP TABLE IF EXISTS `migration_log`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `migration_log` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`filename` varchar(255) DEFAULT NULL,
`executed_at` datetime DEFAULT current_timestamp(),
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `migration_log`
--
LOCK TABLES `migration_log` WRITE;
/*!40000 ALTER TABLE `migration_log` DISABLE KEYS */;
/*!40000 ALTER TABLE `migration_log` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `products`
--
DROP TABLE IF EXISTS `products`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `products` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`group` varchar(255) NOT NULL,
`type` varchar(100) DEFAULT NULL,
`pay_type` varchar(100) DEFAULT NULL,
`auto_setup` varchar(100) DEFAULT NULL,
`url` text DEFAULT NULL,
`module` varchar(100) DEFAULT NULL,
`hidden` tinyint(1) DEFAULT 0,
`created_at` datetime DEFAULT current_timestamp(),
`updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`price` decimal(10,2) NOT NULL DEFAULT 0.00,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `products`
--
LOCK TABLES `products` WRITE;
/*!40000 ALTER TABLE `products` DISABLE KEYS */;
/*!40000 ALTER TABLE `products` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `transactions`
--
DROP TABLE IF EXISTS `transactions`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `transactions` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`invoice_id` int(11) NOT NULL,
`client_id` int(11) NOT NULL,
`amount` decimal(10,2) NOT NULL,
`method` varchar(100) DEFAULT NULL,
`status` enum('success','failed','pending') NOT NULL DEFAULT 'pending',
`notes` text DEFAULT NULL,
`created_at` timestamp NULL DEFAULT current_timestamp(),
PRIMARY KEY (`id`),
KEY `invoice_id` (`invoice_id`),
KEY `client_id` (`client_id`),
CONSTRAINT `transactions_ibfk_1` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`id`) ON DELETE CASCADE,
CONSTRAINT `transactions_ibfk_2` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `transactions`
--
LOCK TABLES `transactions` WRITE;
/*!40000 ALTER TABLE `transactions` DISABLE KEYS */;
/*!40000 ALTER TABLE `transactions` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `users`
--
DROP TABLE IF EXISTS `users`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `users` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`first_name` varchar(100) NOT NULL,
`last_name` varchar(100) NOT NULL,
`email` varchar(150) NOT NULL,
`password` varchar(255) NOT NULL,
`created_at` timestamp NULL DEFAULT current_timestamp(),
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `users`
--
LOCK TABLES `users` WRITE;
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
INSERT INTO `users` VALUES
(2,'დემო','ანგარიში','admin@admin.com','$2y$10$9C9i9frh2rXwZENa1p5C8.45pgAkZwJ3CWMKnYd9nZxr3hhKo0C3C','2025-07-31 10:24:18');
/*!40000 ALTER TABLE `users` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `version_history`
--
DROP TABLE IF EXISTS `version_history`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `version_history` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`version` varchar(20) NOT NULL,
`description` text DEFAULT NULL,
`migration_file` varchar(255) DEFAULT NULL,
`executed_at` timestamp NULL DEFAULT current_timestamp(),
`status` enum('pending','completed','failed') DEFAULT 'pending',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `version_history`
--
LOCK TABLES `version_history` WRITE;
/*!40000 ALTER TABLE `version_history` DISABLE KEYS */;
/*!40000 ALTER TABLE `version_history` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2025-07-31 10:39:26
@@ -0,0 +1,25 @@
<?php
return array (
'host' => 'localhost',
'user' => 'user',
'pass' => 'password',
'dbname' => 'mydb',
'port' => 3306,
'charset' => 'utf8mb4',
'db' =>
array (
'host' => 'localhost',
'user' => 'user',
'pass' => 'password',
'name' => 'mydb',
'port' => 3306,
'charset' => 'utf8mb4',
),
'app' =>
array (
'base_url' => 'http://localhost/',
'debug' => true,
'installed' => true,
'version' => '1.0.0',
),
);
@@ -0,0 +1,340 @@
/*M!999999\- enable the sandbox mode */
-- MariaDB dump 10.19 Distrib 10.11.11-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: localhost Database: mydb
-- ------------------------------------------------------
-- Server version 10.11.11-MariaDB-0+deb12u1
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `clients`
--
DROP TABLE IF EXISTS `clients`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `clients` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`first_name` varchar(100) NOT NULL,
`last_name` varchar(100) NOT NULL,
`company_name` varchar(150) DEFAULT NULL,
`vat_number` varchar(150) DEFAULT NULL,
`email` varchar(150) NOT NULL,
`password` varchar(255) NOT NULL,
`address1` varchar(255) DEFAULT NULL,
`address2` varchar(255) DEFAULT NULL,
`city` varchar(100) DEFAULT NULL,
`state` varchar(100) DEFAULT NULL,
`postcode` varchar(20) DEFAULT NULL,
`country` varchar(2) DEFAULT NULL,
`phone` varchar(50) DEFAULT NULL,
`payment_method` varchar(50) DEFAULT NULL,
`billing_contact` varchar(100) DEFAULT NULL,
`currency` varchar(10) DEFAULT 'USD',
`language` varchar(10) DEFAULT 'default',
`status` enum('active','inactive') DEFAULT 'active',
`client_group` varchar(50) DEFAULT 'none',
`created_at` timestamp NULL DEFAULT current_timestamp(),
`admin_notes` text DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `clients`
--
LOCK TABLES `clients` WRITE;
/*!40000 ALTER TABLE `clients` DISABLE KEYS */;
/*!40000 ALTER TABLE `clients` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `email_logs`
--
DROP TABLE IF EXISTS `email_logs`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `email_logs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`client_id` int(11) NOT NULL,
`subject` varchar(255) DEFAULT NULL,
`message` text DEFAULT NULL,
`sent_at` datetime DEFAULT current_timestamp(),
PRIMARY KEY (`id`),
KEY `client_id` (`client_id`),
CONSTRAINT `email_logs_ibfk_1` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `email_logs`
--
LOCK TABLES `email_logs` WRITE;
/*!40000 ALTER TABLE `email_logs` DISABLE KEYS */;
/*!40000 ALTER TABLE `email_logs` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `email_templates`
--
DROP TABLE IF EXISTS `email_templates`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `email_templates` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`subject` varchar(255) NOT NULL,
`body` text NOT NULL,
`created_at` datetime DEFAULT current_timestamp(),
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `email_templates`
--
LOCK TABLES `email_templates` WRITE;
/*!40000 ALTER TABLE `email_templates` DISABLE KEYS */;
/*!40000 ALTER TABLE `email_templates` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `invoice_items`
--
DROP TABLE IF EXISTS `invoice_items`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `invoice_items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`invoice_id` int(11) NOT NULL,
`product_id` int(11) DEFAULT NULL,
`description` text DEFAULT NULL,
`amount` decimal(10,2) NOT NULL DEFAULT 0.00,
PRIMARY KEY (`id`),
KEY `invoice_id` (`invoice_id`),
CONSTRAINT `invoice_items_ibfk_1` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `invoice_items`
--
LOCK TABLES `invoice_items` WRITE;
/*!40000 ALTER TABLE `invoice_items` DISABLE KEYS */;
/*!40000 ALTER TABLE `invoice_items` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `invoices`
--
DROP TABLE IF EXISTS `invoices`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `invoices` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`invoice_number` varchar(100) DEFAULT NULL,
`client_id` int(11) NOT NULL,
`description` text DEFAULT NULL,
`payment_method` varchar(100) DEFAULT NULL,
`status` enum('დრაფტი','გადაუხდელი','გადასახდელი','გადახდილი','გაუქმებული') NOT NULL DEFAULT 'დრაფტი',
`total_amount` decimal(10,2) NOT NULL DEFAULT 0.00,
`is_recurring` tinyint(1) DEFAULT 0,
`issue_date` date NOT NULL,
`due_date` date NOT NULL,
`payment_date` date DEFAULT NULL,
`created_at` timestamp NULL DEFAULT current_timestamp(),
`recurring` tinyint(1) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `invoice_number` (`invoice_number`),
KEY `client_id` (`client_id`),
CONSTRAINT `invoices_ibfk_1` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `invoices`
--
LOCK TABLES `invoices` WRITE;
/*!40000 ALTER TABLE `invoices` DISABLE KEYS */;
/*!40000 ALTER TABLE `invoices` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `migration_log`
--
DROP TABLE IF EXISTS `migration_log`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `migration_log` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`filename` varchar(255) DEFAULT NULL,
`executed_at` datetime DEFAULT current_timestamp(),
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `migration_log`
--
LOCK TABLES `migration_log` WRITE;
/*!40000 ALTER TABLE `migration_log` DISABLE KEYS */;
/*!40000 ALTER TABLE `migration_log` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `products`
--
DROP TABLE IF EXISTS `products`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `products` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`group` varchar(255) NOT NULL,
`type` varchar(100) DEFAULT NULL,
`pay_type` varchar(100) DEFAULT NULL,
`auto_setup` varchar(100) DEFAULT NULL,
`url` text DEFAULT NULL,
`module` varchar(100) DEFAULT NULL,
`hidden` tinyint(1) DEFAULT 0,
`created_at` datetime DEFAULT current_timestamp(),
`updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`price` decimal(10,2) NOT NULL DEFAULT 0.00,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `products`
--
LOCK TABLES `products` WRITE;
/*!40000 ALTER TABLE `products` DISABLE KEYS */;
/*!40000 ALTER TABLE `products` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `transactions`
--
DROP TABLE IF EXISTS `transactions`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `transactions` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`invoice_id` int(11) NOT NULL,
`client_id` int(11) NOT NULL,
`amount` decimal(10,2) NOT NULL,
`method` varchar(100) DEFAULT NULL,
`status` enum('success','failed','pending') NOT NULL DEFAULT 'pending',
`notes` text DEFAULT NULL,
`created_at` timestamp NULL DEFAULT current_timestamp(),
PRIMARY KEY (`id`),
KEY `invoice_id` (`invoice_id`),
KEY `client_id` (`client_id`),
CONSTRAINT `transactions_ibfk_1` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`id`) ON DELETE CASCADE,
CONSTRAINT `transactions_ibfk_2` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `transactions`
--
LOCK TABLES `transactions` WRITE;
/*!40000 ALTER TABLE `transactions` DISABLE KEYS */;
/*!40000 ALTER TABLE `transactions` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `users`
--
DROP TABLE IF EXISTS `users`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `users` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`first_name` varchar(100) NOT NULL,
`last_name` varchar(100) NOT NULL,
`email` varchar(150) NOT NULL,
`password` varchar(255) NOT NULL,
`created_at` timestamp NULL DEFAULT current_timestamp(),
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `users`
--
LOCK TABLES `users` WRITE;
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
INSERT INTO `users` VALUES
(2,'დემო','ანგარიში','admin@admin.com','$2y$10$9C9i9frh2rXwZENa1p5C8.45pgAkZwJ3CWMKnYd9nZxr3hhKo0C3C','2025-07-31 10:24:18');
/*!40000 ALTER TABLE `users` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `version_history`
--
DROP TABLE IF EXISTS `version_history`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `version_history` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`version` varchar(20) NOT NULL,
`description` text DEFAULT NULL,
`migration_file` varchar(255) DEFAULT NULL,
`executed_at` timestamp NULL DEFAULT current_timestamp(),
`status` enum('pending','completed','failed') DEFAULT 'pending',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `version_history`
--
LOCK TABLES `version_history` WRITE;
/*!40000 ALTER TABLE `version_history` DISABLE KEYS */;
INSERT INTO `version_history` VALUES
(1,'1.0.1','add phone column to users table','1.0.1_add_phone_column_to_users_table.php','2025-07-31 10:39:26','pending');
/*!40000 ALTER TABLE `version_history` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2025-07-31 10:39:31
@@ -0,0 +1,25 @@
<?php
return array (
'host' => 'localhost',
'user' => 'user',
'pass' => 'password',
'dbname' => 'mydb',
'port' => 3306,
'charset' => 'utf8mb4',
'db' =>
array (
'host' => 'localhost',
'user' => 'user',
'pass' => 'password',
'name' => 'mydb',
'port' => 3306,
'charset' => 'utf8mb4',
),
'app' =>
array (
'base_url' => 'http://localhost/',
'debug' => true,
'installed' => true,
'version' => '1.0.0',
),
);
@@ -0,0 +1,341 @@
/*M!999999\- enable the sandbox mode */
-- MariaDB dump 10.19 Distrib 10.11.11-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: localhost Database: mydb
-- ------------------------------------------------------
-- Server version 10.11.11-MariaDB-0+deb12u1
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `clients`
--
DROP TABLE IF EXISTS `clients`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `clients` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`first_name` varchar(100) NOT NULL,
`last_name` varchar(100) NOT NULL,
`company_name` varchar(150) DEFAULT NULL,
`vat_number` varchar(150) DEFAULT NULL,
`email` varchar(150) NOT NULL,
`password` varchar(255) NOT NULL,
`address1` varchar(255) DEFAULT NULL,
`address2` varchar(255) DEFAULT NULL,
`city` varchar(100) DEFAULT NULL,
`state` varchar(100) DEFAULT NULL,
`postcode` varchar(20) DEFAULT NULL,
`country` varchar(2) DEFAULT NULL,
`phone` varchar(50) DEFAULT NULL,
`payment_method` varchar(50) DEFAULT NULL,
`billing_contact` varchar(100) DEFAULT NULL,
`currency` varchar(10) DEFAULT 'USD',
`language` varchar(10) DEFAULT 'default',
`status` enum('active','inactive') DEFAULT 'active',
`client_group` varchar(50) DEFAULT 'none',
`created_at` timestamp NULL DEFAULT current_timestamp(),
`admin_notes` text DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `clients`
--
LOCK TABLES `clients` WRITE;
/*!40000 ALTER TABLE `clients` DISABLE KEYS */;
/*!40000 ALTER TABLE `clients` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `email_logs`
--
DROP TABLE IF EXISTS `email_logs`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `email_logs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`client_id` int(11) NOT NULL,
`subject` varchar(255) DEFAULT NULL,
`message` text DEFAULT NULL,
`sent_at` datetime DEFAULT current_timestamp(),
PRIMARY KEY (`id`),
KEY `client_id` (`client_id`),
CONSTRAINT `email_logs_ibfk_1` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `email_logs`
--
LOCK TABLES `email_logs` WRITE;
/*!40000 ALTER TABLE `email_logs` DISABLE KEYS */;
/*!40000 ALTER TABLE `email_logs` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `email_templates`
--
DROP TABLE IF EXISTS `email_templates`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `email_templates` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`subject` varchar(255) NOT NULL,
`body` text NOT NULL,
`created_at` datetime DEFAULT current_timestamp(),
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `email_templates`
--
LOCK TABLES `email_templates` WRITE;
/*!40000 ALTER TABLE `email_templates` DISABLE KEYS */;
/*!40000 ALTER TABLE `email_templates` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `invoice_items`
--
DROP TABLE IF EXISTS `invoice_items`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `invoice_items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`invoice_id` int(11) NOT NULL,
`product_id` int(11) DEFAULT NULL,
`description` text DEFAULT NULL,
`amount` decimal(10,2) NOT NULL DEFAULT 0.00,
PRIMARY KEY (`id`),
KEY `invoice_id` (`invoice_id`),
CONSTRAINT `invoice_items_ibfk_1` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `invoice_items`
--
LOCK TABLES `invoice_items` WRITE;
/*!40000 ALTER TABLE `invoice_items` DISABLE KEYS */;
/*!40000 ALTER TABLE `invoice_items` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `invoices`
--
DROP TABLE IF EXISTS `invoices`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `invoices` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`invoice_number` varchar(100) DEFAULT NULL,
`client_id` int(11) NOT NULL,
`description` text DEFAULT NULL,
`payment_method` varchar(100) DEFAULT NULL,
`status` enum('დრაფტი','გადაუხდელი','გადასახდელი','გადახდილი','გაუქმებული') NOT NULL DEFAULT 'დრაფტი',
`total_amount` decimal(10,2) NOT NULL DEFAULT 0.00,
`is_recurring` tinyint(1) DEFAULT 0,
`issue_date` date NOT NULL,
`due_date` date NOT NULL,
`payment_date` date DEFAULT NULL,
`created_at` timestamp NULL DEFAULT current_timestamp(),
`recurring` tinyint(1) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `invoice_number` (`invoice_number`),
KEY `client_id` (`client_id`),
CONSTRAINT `invoices_ibfk_1` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `invoices`
--
LOCK TABLES `invoices` WRITE;
/*!40000 ALTER TABLE `invoices` DISABLE KEYS */;
/*!40000 ALTER TABLE `invoices` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `migration_log`
--
DROP TABLE IF EXISTS `migration_log`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `migration_log` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`filename` varchar(255) DEFAULT NULL,
`executed_at` datetime DEFAULT current_timestamp(),
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `migration_log`
--
LOCK TABLES `migration_log` WRITE;
/*!40000 ALTER TABLE `migration_log` DISABLE KEYS */;
/*!40000 ALTER TABLE `migration_log` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `products`
--
DROP TABLE IF EXISTS `products`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `products` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`group` varchar(255) NOT NULL,
`type` varchar(100) DEFAULT NULL,
`pay_type` varchar(100) DEFAULT NULL,
`auto_setup` varchar(100) DEFAULT NULL,
`url` text DEFAULT NULL,
`module` varchar(100) DEFAULT NULL,
`hidden` tinyint(1) DEFAULT 0,
`created_at` datetime DEFAULT current_timestamp(),
`updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`price` decimal(10,2) NOT NULL DEFAULT 0.00,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `products`
--
LOCK TABLES `products` WRITE;
/*!40000 ALTER TABLE `products` DISABLE KEYS */;
/*!40000 ALTER TABLE `products` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `transactions`
--
DROP TABLE IF EXISTS `transactions`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `transactions` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`invoice_id` int(11) NOT NULL,
`client_id` int(11) NOT NULL,
`amount` decimal(10,2) NOT NULL,
`method` varchar(100) DEFAULT NULL,
`status` enum('success','failed','pending') NOT NULL DEFAULT 'pending',
`notes` text DEFAULT NULL,
`created_at` timestamp NULL DEFAULT current_timestamp(),
PRIMARY KEY (`id`),
KEY `invoice_id` (`invoice_id`),
KEY `client_id` (`client_id`),
CONSTRAINT `transactions_ibfk_1` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`id`) ON DELETE CASCADE,
CONSTRAINT `transactions_ibfk_2` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `transactions`
--
LOCK TABLES `transactions` WRITE;
/*!40000 ALTER TABLE `transactions` DISABLE KEYS */;
/*!40000 ALTER TABLE `transactions` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `users`
--
DROP TABLE IF EXISTS `users`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `users` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`first_name` varchar(100) NOT NULL,
`last_name` varchar(100) NOT NULL,
`email` varchar(150) NOT NULL,
`password` varchar(255) NOT NULL,
`created_at` timestamp NULL DEFAULT current_timestamp(),
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `users`
--
LOCK TABLES `users` WRITE;
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
INSERT INTO `users` VALUES
(2,'დემო','ანგარიში','admin@admin.com','$2y$10$9C9i9frh2rXwZENa1p5C8.45pgAkZwJ3CWMKnYd9nZxr3hhKo0C3C','2025-07-31 10:24:18');
/*!40000 ALTER TABLE `users` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `version_history`
--
DROP TABLE IF EXISTS `version_history`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `version_history` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`version` varchar(20) NOT NULL,
`description` text DEFAULT NULL,
`migration_file` varchar(255) DEFAULT NULL,
`executed_at` timestamp NULL DEFAULT current_timestamp(),
`status` enum('pending','completed','failed') DEFAULT 'pending',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `version_history`
--
LOCK TABLES `version_history` WRITE;
/*!40000 ALTER TABLE `version_history` DISABLE KEYS */;
INSERT INTO `version_history` VALUES
(1,'1.0.1','add phone column to users table','1.0.1_add_phone_column_to_users_table.php','2025-07-31 10:39:26','pending'),
(2,'1.0.1','add phone column to users table','1.0.1_add_phone_column_to_users_table.php','2025-07-31 10:39:31','pending');
/*!40000 ALTER TABLE `version_history` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2025-07-31 10:41:30
@@ -0,0 +1,25 @@
<?php
return array (
'host' => 'localhost',
'user' => 'user',
'pass' => 'password',
'dbname' => 'mydb',
'port' => 3306,
'charset' => 'utf8mb4',
'db' =>
array (
'host' => 'localhost',
'user' => 'user',
'pass' => 'password',
'name' => 'mydb',
'port' => 3306,
'charset' => 'utf8mb4',
),
'app' =>
array (
'base_url' => 'http://localhost/',
'debug' => true,
'installed' => true,
'version' => '1.0.0',
),
);
@@ -0,0 +1,342 @@
/*M!999999\- enable the sandbox mode */
-- MariaDB dump 10.19 Distrib 10.11.11-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: localhost Database: mydb
-- ------------------------------------------------------
-- Server version 10.11.11-MariaDB-0+deb12u1
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `clients`
--
DROP TABLE IF EXISTS `clients`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `clients` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`first_name` varchar(100) NOT NULL,
`last_name` varchar(100) NOT NULL,
`company_name` varchar(150) DEFAULT NULL,
`vat_number` varchar(150) DEFAULT NULL,
`email` varchar(150) NOT NULL,
`password` varchar(255) NOT NULL,
`address1` varchar(255) DEFAULT NULL,
`address2` varchar(255) DEFAULT NULL,
`city` varchar(100) DEFAULT NULL,
`state` varchar(100) DEFAULT NULL,
`postcode` varchar(20) DEFAULT NULL,
`country` varchar(2) DEFAULT NULL,
`phone` varchar(50) DEFAULT NULL,
`payment_method` varchar(50) DEFAULT NULL,
`billing_contact` varchar(100) DEFAULT NULL,
`currency` varchar(10) DEFAULT 'USD',
`language` varchar(10) DEFAULT 'default',
`status` enum('active','inactive') DEFAULT 'active',
`client_group` varchar(50) DEFAULT 'none',
`created_at` timestamp NULL DEFAULT current_timestamp(),
`admin_notes` text DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `clients`
--
LOCK TABLES `clients` WRITE;
/*!40000 ALTER TABLE `clients` DISABLE KEYS */;
/*!40000 ALTER TABLE `clients` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `email_logs`
--
DROP TABLE IF EXISTS `email_logs`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `email_logs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`client_id` int(11) NOT NULL,
`subject` varchar(255) DEFAULT NULL,
`message` text DEFAULT NULL,
`sent_at` datetime DEFAULT current_timestamp(),
PRIMARY KEY (`id`),
KEY `client_id` (`client_id`),
CONSTRAINT `email_logs_ibfk_1` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `email_logs`
--
LOCK TABLES `email_logs` WRITE;
/*!40000 ALTER TABLE `email_logs` DISABLE KEYS */;
/*!40000 ALTER TABLE `email_logs` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `email_templates`
--
DROP TABLE IF EXISTS `email_templates`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `email_templates` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`subject` varchar(255) NOT NULL,
`body` text NOT NULL,
`created_at` datetime DEFAULT current_timestamp(),
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `email_templates`
--
LOCK TABLES `email_templates` WRITE;
/*!40000 ALTER TABLE `email_templates` DISABLE KEYS */;
/*!40000 ALTER TABLE `email_templates` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `invoice_items`
--
DROP TABLE IF EXISTS `invoice_items`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `invoice_items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`invoice_id` int(11) NOT NULL,
`product_id` int(11) DEFAULT NULL,
`description` text DEFAULT NULL,
`amount` decimal(10,2) NOT NULL DEFAULT 0.00,
PRIMARY KEY (`id`),
KEY `invoice_id` (`invoice_id`),
CONSTRAINT `invoice_items_ibfk_1` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `invoice_items`
--
LOCK TABLES `invoice_items` WRITE;
/*!40000 ALTER TABLE `invoice_items` DISABLE KEYS */;
/*!40000 ALTER TABLE `invoice_items` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `invoices`
--
DROP TABLE IF EXISTS `invoices`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `invoices` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`invoice_number` varchar(100) DEFAULT NULL,
`client_id` int(11) NOT NULL,
`description` text DEFAULT NULL,
`payment_method` varchar(100) DEFAULT NULL,
`status` enum('დრაფტი','გადაუხდელი','გადასახდელი','გადახდილი','გაუქმებული') NOT NULL DEFAULT 'დრაფტი',
`total_amount` decimal(10,2) NOT NULL DEFAULT 0.00,
`is_recurring` tinyint(1) DEFAULT 0,
`issue_date` date NOT NULL,
`due_date` date NOT NULL,
`payment_date` date DEFAULT NULL,
`created_at` timestamp NULL DEFAULT current_timestamp(),
`recurring` tinyint(1) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `invoice_number` (`invoice_number`),
KEY `client_id` (`client_id`),
CONSTRAINT `invoices_ibfk_1` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `invoices`
--
LOCK TABLES `invoices` WRITE;
/*!40000 ALTER TABLE `invoices` DISABLE KEYS */;
/*!40000 ALTER TABLE `invoices` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `migration_log`
--
DROP TABLE IF EXISTS `migration_log`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `migration_log` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`filename` varchar(255) DEFAULT NULL,
`executed_at` datetime DEFAULT current_timestamp(),
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `migration_log`
--
LOCK TABLES `migration_log` WRITE;
/*!40000 ALTER TABLE `migration_log` DISABLE KEYS */;
/*!40000 ALTER TABLE `migration_log` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `products`
--
DROP TABLE IF EXISTS `products`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `products` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`group` varchar(255) NOT NULL,
`type` varchar(100) DEFAULT NULL,
`pay_type` varchar(100) DEFAULT NULL,
`auto_setup` varchar(100) DEFAULT NULL,
`url` text DEFAULT NULL,
`module` varchar(100) DEFAULT NULL,
`hidden` tinyint(1) DEFAULT 0,
`created_at` datetime DEFAULT current_timestamp(),
`updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`price` decimal(10,2) NOT NULL DEFAULT 0.00,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `products`
--
LOCK TABLES `products` WRITE;
/*!40000 ALTER TABLE `products` DISABLE KEYS */;
/*!40000 ALTER TABLE `products` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `transactions`
--
DROP TABLE IF EXISTS `transactions`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `transactions` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`invoice_id` int(11) NOT NULL,
`client_id` int(11) NOT NULL,
`amount` decimal(10,2) NOT NULL,
`method` varchar(100) DEFAULT NULL,
`status` enum('success','failed','pending') NOT NULL DEFAULT 'pending',
`notes` text DEFAULT NULL,
`created_at` timestamp NULL DEFAULT current_timestamp(),
PRIMARY KEY (`id`),
KEY `invoice_id` (`invoice_id`),
KEY `client_id` (`client_id`),
CONSTRAINT `transactions_ibfk_1` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`id`) ON DELETE CASCADE,
CONSTRAINT `transactions_ibfk_2` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `transactions`
--
LOCK TABLES `transactions` WRITE;
/*!40000 ALTER TABLE `transactions` DISABLE KEYS */;
/*!40000 ALTER TABLE `transactions` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `users`
--
DROP TABLE IF EXISTS `users`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `users` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`first_name` varchar(100) NOT NULL,
`last_name` varchar(100) NOT NULL,
`email` varchar(150) NOT NULL,
`password` varchar(255) NOT NULL,
`created_at` timestamp NULL DEFAULT current_timestamp(),
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `users`
--
LOCK TABLES `users` WRITE;
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
INSERT INTO `users` VALUES
(2,'დემო','ანგარიში','admin@admin.com','$2y$10$9C9i9frh2rXwZENa1p5C8.45pgAkZwJ3CWMKnYd9nZxr3hhKo0C3C','2025-07-31 10:24:18');
/*!40000 ALTER TABLE `users` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `version_history`
--
DROP TABLE IF EXISTS `version_history`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `version_history` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`version` varchar(20) NOT NULL,
`description` text DEFAULT NULL,
`migration_file` varchar(255) DEFAULT NULL,
`executed_at` timestamp NULL DEFAULT current_timestamp(),
`status` enum('pending','completed','failed') DEFAULT 'pending',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `version_history`
--
LOCK TABLES `version_history` WRITE;
/*!40000 ALTER TABLE `version_history` DISABLE KEYS */;
INSERT INTO `version_history` VALUES
(1,'1.0.1','add phone column to users table','1.0.1_add_phone_column_to_users_table.php','2025-07-31 10:39:26','pending'),
(2,'1.0.1','add phone column to users table','1.0.1_add_phone_column_to_users_table.php','2025-07-31 10:39:31','pending'),
(3,'1.0.1','add phone column to users table','1.0.1_add_phone_column_to_users_table.php','2025-07-31 10:41:30','pending');
/*!40000 ALTER TABLE `version_history` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2025-07-31 10:41:46
+65
View File
@@ -0,0 +1,65 @@
<?php
require_once '/var/www/billingerp/admin/includes/db.php';
try {
// ვამოწმებთ users ცხრილის სტრუქტურას
$stmt = $pdo->query("DESCRIBE users");
$columns = $stmt->fetchAll(PDO::FETCH_COLUMN);
echo "✅ Users ცხრილის მიმდინარე სტრუქტურა:\n";
foreach ($columns as $column) {
echo " - $column\n";
}
// ვამოწმებთ საჭირო სვეტები
$requiredColumns = ['role', 'is_active', 'updated_at'];
$missingColumns = [];
foreach ($requiredColumns as $requiredColumn) {
if (!in_array($requiredColumn, $columns)) {
$missingColumns[] = $requiredColumn;
}
}
if (!empty($missingColumns)) {
echo "\n🔧 დაკლებული სვეტების დამატება:\n";
foreach ($missingColumns as $column) {
switch ($column) {
case 'role':
$sql = "ALTER TABLE users ADD COLUMN role VARCHAR(20) DEFAULT 'user'";
$pdo->exec($sql);
echo " ✅ role სვეტი დაემატა\n";
break;
case 'is_active':
$sql = "ALTER TABLE users ADD COLUMN is_active TINYINT(1) DEFAULT 1";
$pdo->exec($sql);
echo " ✅ is_active სვეტი დაემატა\n";
break;
case 'updated_at':
$sql = "ALTER TABLE users ADD COLUMN updated_at TIMESTAMP NULL ON UPDATE CURRENT_TIMESTAMP";
$pdo->exec($sql);
echo " ✅ updated_at სვეტი დაემატა\n";
break;
}
}
// default admin role-ის დაყენება
$pdo->exec("UPDATE users SET role = 'admin' WHERE id = 1");
echo " ✅ Default admin role დაყენდა\n";
} else {
echo "\n✅ ყველა საჭირო სვეტი არსებობს!\n";
}
// Users-ების რაოდენობის შემოწმება
$stmt = $pdo->query("SELECT COUNT(*) FROM users");
$userCount = $stmt->fetchColumn();
echo "\n📊 სისტემაში არსებული მომხმარებლების რაოდენობა: $userCount\n";
} catch (PDOException $e) {
echo "❌ შეცდომა: " . $e->getMessage() . "\n";
}
?>
@@ -0,0 +1,42 @@
<?php
require_once '/var/www/billingerp/admin/includes/db.php';
// Product types ცხრილის შექმნა
$sql = "CREATE TABLE IF NOT EXISTS product_types (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL UNIQUE,
description TEXT,
icon VARCHAR(50),
sort_order INT DEFAULT 0,
is_active TINYINT(1) DEFAULT 1,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
)";
try {
$pdo->exec($sql);
echo "✅ Product types ცხრილი შეიქმნა წარმატებით\n";
// Default product types-ების ჩასმა
$defaultTypes = [
['Shared Hosting', 'გაზიარებული ჰოსტინგი - იაფი და მარტივი', 'server', 1],
['Reseller Hosting', 'რესელერული ჰოსტინგი - ბიზნესისთვის', 'users', 2],
['Server/VPS', 'ვირტუალური/დედიკატირებული სერვერი', 'server-2', 3],
['Domain Registration', 'დომენის რეგისტრაცია', 'world', 4],
['SSL Certificate', 'SSL სერტიფიკატი', 'shield-check', 5],
['Email Hosting', 'ელ.ფოსტის ჰოსტინგი', 'mail', 6],
['Cloud Storage', 'ღრუბლოვანი საცავი', 'cloud', 7],
['Other', 'სხვა სერვისები', 'dots', 8]
];
$stmt = $pdo->prepare("INSERT IGNORE INTO product_types (name, description, icon, sort_order) VALUES (?, ?, ?, ?)");
foreach ($defaultTypes as $type) {
$stmt->execute($type);
}
echo "✅ Default product types დაემატა\n";
} catch (PDOException $e) {
echo "❌ შეცდომა: " . $e->getMessage() . "\n";
}
?>
+41
View File
@@ -0,0 +1,41 @@
<?php
require_once '/var/www/billingerp/admin/includes/db.php';
// SMTP settings ცხრილის შექმნა
$sql = "CREATE TABLE IF NOT EXISTS smtp_settings (
id INT AUTO_INCREMENT PRIMARY KEY,
setting_key VARCHAR(100) NOT NULL UNIQUE,
setting_value TEXT,
description VARCHAR(255),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
)";
try {
$pdo->exec($sql);
echo "✅ SMTP settings ცხრილი შეიქმნა წარმატებით\n";
// Default settings-ების ჩასმა
$defaultSettings = [
['smtp_host', 'vps-7146dd3a.vps.ovh.ca', 'SMTP სერვერის მისამართი'],
['smtp_port', '465', 'SMTP პორტი'],
['smtp_secure', 'ssl', 'SMTP უსაფრთხოება (ssl/tls)'],
['smtp_auth', '1', 'SMTP ავტორიზაცია (0/1)'],
['smtp_username', 'noreply@selfhosting.ge', 'SMTP მომხმარებლის სახელი'],
['smtp_password', 'FSZtTIIIlubk', 'SMTP პაროლი'],
['smtp_from_email', 'noreply@selfhosting.ge', 'გამომგზავნის ელ.ფოსტა'],
['smtp_from_name', 'SelfHosting.ge', 'გამომგზავნის სახელი'],
['smtp_debug', '0', 'Debug რეჟიმი (0-2)']
];
$stmt = $pdo->prepare("INSERT IGNORE INTO smtp_settings (setting_key, setting_value, description) VALUES (?, ?, ?)");
foreach ($defaultSettings as $setting) {
$stmt->execute($setting);
}
echo "✅ Default SMTP settings დაემატა\n";
} catch (PDOException $e) {
echo "❌ შეცდომა: " . $e->getMessage() . "\n";
}
?>
+25
View File
@@ -0,0 +1,25 @@
<?php
// ამ ფაილს მხოლოდ მიგრაციების სისტემა იყენებს
// თქვენი არსებული db.php არ შეიცვლება
$configFile = __DIR__ . '/../config.php';
if (!file_exists($configFile)) {
die('მიგრაციის კონფიგურაცია ვერ მოიძებნა');
}
$config = include $configFile;
// PDO კავშირი მხოლოდ მიგრაციებისთვის
$host = $config['host'] ?? $config['db']['host'] ?? 'localhost';
$db = $config['dbname'] ?? $config['db']['name'] ?? '';
$user = $config['user'] ?? $config['db']['user'] ?? '';
$pass = $config['pass'] ?? $config['db']['pass'] ?? '';
try {
$pdo = new PDO("mysql:host=$host;dbname=$db;charset=utf8mb4", $user, $pass);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
die("ბაზასთან კავშირის შეცდომა: " . $e->getMessage());
}
?>
+383
View File
@@ -0,0 +1,383 @@
<?php
session_start();
require_once __DIR__ . '/../includes/db.php';
require_once __DIR__ . '/UpdateManager.php';
// ავტორიზაციის შემოწმება
if (!isset($_SESSION['user_id'])) {
header('Location: ../login.php');
exit;
}
$updateManager = new UpdateManager($pdo);
$message = '';
$messageType = '';
// განახლების გაშვება
if ($_POST['action'] ?? '' === 'run_update') {
$version = $_POST['version'] ?? '';
try {
$result = $updateManager->runUpdate($version);
$message = $result['message'];
$messageType = 'success';
} catch (Exception $e) {
$message = $e->getMessage();
$messageType = 'danger';
}
}
// ყველა განახლების გაშვება
if ($_POST['action'] ?? '' === 'run_all_updates') {
try {
$results = $updateManager->runAllUpdates();
$messages = [];
foreach ($results as $result) {
$messages[] = $result['message'];
}
$message = implode('<br>', $messages);
$messageType = 'success';
} catch (Exception $e) {
$message = $e->getMessage();
$messageType = 'danger';
}
}
// ახალი მიგრაციის შექმნა
if ($_POST['action'] ?? '' === 'create_migration') {
$version = $_POST['new_version'] ?? '';
$description = $_POST['description'] ?? '';
$upSql = $_POST['up_sql'] ?? '';
$downSql = $_POST['down_sql'] ?? '';
// ვალიდაცია
if (empty($version) || empty($description) || empty($upSql)) {
$message = "გთხოვთ შეავსოთ ყველა სავალდებულო ველი.";
$messageType = 'danger';
} elseif (!preg_match('/^\d+\.\d+\.\d+$/', $version)) {
$message = "ვერსია უნდა იყოს X.Y.Z ფორმატში (მაგ: 1.0.3)";
$messageType = 'danger';
} else {
try {
// შევამოწმოთ არ არსებობს თუ არა უკვე ასეთი ვერსია
$existingUpdates = $updateManager->getAvailableUpdates();
foreach ($existingUpdates as $update) {
if ($update['version'] === $version) {
throw new Exception("ვერსია $version უკვე არსებობს");
}
}
// შევამოწმოთ ვერსიების ისტორიაში
$history = $updateManager->getUpdateHistory();
foreach ($history as $record) {
if ($record['version'] === $version) {
throw new Exception("ვერსია $version უკვე გამოყენებულია");
}
}
$result = $updateManager->createMigration($version, $description, $upSql, $downSql);
$message = $result['message'];
$messageType = 'success';
} catch (Exception $e) {
$message = "შეცდომა: " . $e->getMessage();
$messageType = 'danger';
}
}
}
$currentVersion = $updateManager->getCurrentVersion();
$availableUpdates = $updateManager->getAvailableUpdates();
$updateHistory = $updateManager->getUpdateHistory();
?>
<!DOCTYPE html>
<html lang="ka">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>STACK - განახლებების მართვა</title>
<link href="../dist/css/tabler.min.css" rel="stylesheet" />
<style>
.code-block { background: #f8f9fa; padding: 15px; border-radius: 5px; font-family: monospace; margin: 10px 0; }
.version-badge { font-size: 0.875em; }
</style>
</head>
<body>
<div class="page">
<div class="page-wrapper">
<div class="container-xl">
<!-- Header -->
<div class="page-header d-print-none">
<div class="row align-items-center">
<div class="col">
<h2 class="page-title">STACK - განახლებების მართვა</h2>
<div class="text-muted mt-1">
მიმდინარე ვერსია: <span class="badge bg-dark"><?= htmlspecialchars($currentVersion) ?></span>
</div>
</div>
<div class="col-auto">
<a href="../dashboard.php" class="btn btn-outline-primary">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-arrow-left">
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<path d="M5 12l14 0"/>
<path d="M5 12l6 6"/>
<path d="M5 12l6 -6"/>
</svg>
უკან დაბრუნება
</a>
</div>
</div>
</div>
<!-- Messages -->
<?php if ($message): ?>
<div class="alert alert-<?= $messageType ?> alert-dismissible">
<div class="d-flex">
<div><?= $message ?></div>
</div>
<a class="btn-close" data-bs-dismiss="alert" aria-label="close"></a>
</div>
<?php endif; ?>
<div class="row">
<!-- ხელმისაწვდომი განახლებები -->
<div class="col-md-8">
<div class="card">
<div class="card-header">
<h3 class="card-title">ხელმისაწვდომი განახლებები</h3>
<?php if (count($availableUpdates) > 1): ?>
<div class="card-actions">
<form method="post" style="display: inline;">
<input type="hidden" name="action" value="run_all_updates">
<button type="submit" class="btn btn-success btn-sm" onclick="return confirm('ყველა განახლების გაშვება?')">
ყველას გაშვება
</button>
</form>
</div>
<?php endif; ?>
</div>
<div class="card-body">
<?php if (empty($availableUpdates)): ?>
<div class="text-center text-muted py-4">
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon mb-3 text-green">
<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/>
<polyline points="22,4 12,14.01 9,11.01"/>
</svg>
<h3>ყველაფერი განახლებულია!</h3>
<p class="text-muted">ახალი განახლებები ხელმისაწვდომი არ არის.</p>
</div>
<?php else: ?>
<div class="list-group list-group-flush">
<?php foreach ($availableUpdates as $update): ?>
<div class="list-group-item">
<div class="row align-items-center">
<div class="col">
<strong>ვერსია <?= htmlspecialchars($update['version']) ?></strong>
<div class="text-muted"><?= htmlspecialchars($update['description']) ?></div>
<small class="text-muted">ფაილი: <?= htmlspecialchars($update['filename']) ?></small>
</div>
<div class="col-auto">
<form method="post" style="display: inline;">
<input type="hidden" name="action" value="run_update">
<input type="hidden" name="version" value="<?= htmlspecialchars($update['version']) ?>">
<button type="submit" class="btn btn-primary btn-sm" onclick="return confirm('განახლების გაშვება?')">
გაშვება
</button>
</form>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
</div>
<!-- განახლებების ისტორია -->
<div class="card mt-4">
<div class="card-header">
<h3 class="card-title">განახლებების ისტორია</h3>
</div>
<div class="card-body">
<?php if (empty($updateHistory)): ?>
<p class="text-muted">განახლებების ისტორია ცარიელია.</p>
<?php else: ?>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>ვერსია</th>
<th>აღწერა</th>
<th>სტატუსი</th>
<th>თარიღი</th>
</tr>
</thead>
<tbody>
<?php foreach ($updateHistory as $history): ?>
<tr>
<td><span class="badge bg-secondary version-badge"><?= htmlspecialchars($history['version']) ?></span></td>
<td><?= htmlspecialchars($history['description']) ?></td>
<td>
<?php
$statusClass = [
'completed' => 'success',
'failed' => 'danger',
'pending' => 'warning'
];
$statusText = [
'completed' => 'დასრულებული',
'failed' => 'ვერ შესრულდა',
'pending' => 'მუშავდება'
];
?>
<span class="badge bg-<?= $statusClass[$history['status']] ?>">
<?= $statusText[$history['status']] ?>
</span>
</td>
<td><?= date('Y-m-d H:i', strtotime($history['executed_at'])) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</div>
</div>
</div>
<!-- ახალი მიგრაციის შექმნა -->
<div class="col-md-4">
<div class="card">
<div class="card-header">
<h3 class="card-title">ახალი მიგრაციის შექმნა</h3>
</div>
<div class="card-body">
<form method="post">
<input type="hidden" name="action" value="create_migration">
<div class="mb-3">
<label class="form-label">ვერსია</label>
<?php
// შემოთავაზებული შემდეგი ვერსია
$parts = explode('.', $currentVersion);
$nextMinor = $parts[0] . '.' . $parts[1] . '.' . ((int)$parts[2] + 1);
$nextMajor = $parts[0] . '.' . ((int)$parts[1] + 1) . '.0';
?>
<input type="text" name="new_version" class="form-control" placeholder="<?= $nextMinor ?>" required>
<small class="form-hint">
ფორმატი: X.Y.Z | შემოთავაზებული:
<a href="#" onclick="document.querySelector('[name=new_version]').value='<?= $nextMinor ?>'; return false;"><?= $nextMinor ?></a> |
<a href="#" onclick="document.querySelector('[name=new_version]').value='<?= $nextMajor ?>'; return false;"><?= $nextMajor ?></a>
</small>
</div>
<div class="mb-3">
<label class="form-label">აღწერა</label>
<input type="text" name="description" class="form-control" placeholder="მაგ: Add new column to users table" required>
</div>
<div class="mb-3">
<label class="form-label">SQL (UP)</label>
<textarea name="up_sql" class="form-control" rows="4" placeholder="ALTER TABLE users ADD COLUMN phone VARCHAR(20);" required></textarea>
<small class="form-hint">განახლების SQL</small>
</div>
<div class="mb-3">
<label class="form-label">SQL (DOWN) - არასავალდებულო</label>
<textarea name="down_sql" class="form-control" rows="4" placeholder="ALTER TABLE users DROP COLUMN phone;"></textarea>
<small class="form-hint">Rollback SQL</small>
</div>
<button type="submit" class="btn btn-primary w-100">მიგრაციის შექმნა</button>
</form>
</div>
</div>
<!-- სასარგებლო ინფორმაცია -->
<div class="card mt-4">
<div class="card-header">
<h3 class="card-title">სასარგებლო ინფორმაცია</h3>
</div>
<div class="card-body">
<div class="mb-3">
<strong>მიგრაციის ფაილების ლოკაცია:</strong>
<div class="code-block">/admin/update/migrations/</div>
</div>
<div class="mb-3">
<strong>Backup ფაილები:</strong>
<div class="code-block">/admin/update/backups/</div>
</div>
<div class="alert alert-info">
<h4>მნიშვნელოვანი!</h4>
<ul class="mb-0">
<li>ყოველი განახლების წინ ავტომატურად იქმნება backup</li>
<li>მიგრაციის ფაილები უნდა იყოს ვერსია_აღწერა.php ფორმატში</li>
<li>ვერსიები ეშვება თანმიმდევრულად</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="../dist/js/tabler.min.js"></script>
<script>
// მიგრაციის ფორმის validation
document.addEventListener('DOMContentLoaded', function() {
const migrationForm = document.querySelector('form[method="post"]');
const versionInput = document.querySelector('input[name="new_version"]');
const descriptionInput = document.querySelector('input[name="description"]');
const upSqlInput = document.querySelector('textarea[name="up_sql"]');
if (migrationForm) {
migrationForm.addEventListener('submit', function(e) {
let errors = [];
// ვერსიის ვალიდაცია
const version = versionInput.value.trim();
if (!version) {
errors.push('ვერსია სავალდებულოა');
} else if (!/^\d+\.\d+\.\d+$/.test(version)) {
errors.push('ვერსია უნდა იყოს X.Y.Z ფორმატში (მაგ: 1.0.3)');
}
// აღწერის ვალიდაცია
if (!descriptionInput.value.trim()) {
errors.push('აღწერა სავალდებულოა');
}
// SQL-ის ვალიდაცია
if (!upSqlInput.value.trim()) {
errors.push('SQL (UP) სავალდებულოა');
}
if (errors.length > 0) {
alert('შეცდომები:\n' + errors.join('\n'));
e.preventDefault();
return false;
}
return confirm('დარწმუნებული ხართ რომ გსურთ მიგრაციის შექმნა?');
});
}
// ვერსიის real-time validation
if (versionInput) {
versionInput.addEventListener('input', function() {
const value = this.value;
if (value && !/^\d+\.\d+\.\d+$/.test(value)) {
this.style.borderColor = '#dc3545';
this.title = 'ვერსია უნდა იყოს X.Y.Z ფორმატში';
} else {
this.style.borderColor = '';
this.title = '';
}
});
}
});
</script>
</body>
</html>
@@ -0,0 +1,32 @@
<?php
/**
* Migration: Add phone column to users table
* Version: 1.0.1
* Created: 2025-07-31 09:30:00
*/
try {
// განახლების SQL
$upSql = "ALTER TABLE users ADD COLUMN phone VARCHAR(20) DEFAULT NULL AFTER email";
if ($upSql) {
$pdo->exec($upSql);
echo "✅ Add phone column to users table - წარმატებით შესრულდა\n";
}
} catch (Exception $e) {
// Rollback SQL (არასავალდებულო)
$downSql = "ALTER TABLE users DROP COLUMN phone";
if ($downSql) {
try {
$pdo->exec($downSql);
echo "⚠️ Rollback SQL შესრულდა\n";
} catch (Exception $rollbackError) {
echo "❌ Rollback შეცდომა: " . $rollbackError->getMessage() . "\n";
}
}
throw new Exception("Add phone column to users table - შეცდომა: " . $e->getMessage());
}
?>
@@ -0,0 +1,53 @@
<?php
/**
* Migration: Add settings table
* Version: 1.0.2
* Created: 2025-07-31 09:35:00
*/
try {
// განახლების SQL
$upSql = "CREATE TABLE IF NOT EXISTS system_settings (
id INT AUTO_INCREMENT PRIMARY KEY,
setting_key VARCHAR(100) UNIQUE NOT NULL,
setting_value TEXT,
description TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
)";
if ($upSql) {
$pdo->exec($upSql);
// დაყენება default settings
$defaultSettings = [
['app_name', 'BillingERP', 'აპლიკაციის სახელი'],
['app_version', '1.0.2', 'აპლიკაციის ვერსია'],
['maintenance_mode', '0', 'მოვლის რეჟიმი'],
['max_file_size', '10485760', 'ფაილის მაქსიმალური ზომა (bytes)']
];
$stmt = $pdo->prepare("INSERT IGNORE INTO system_settings (setting_key, setting_value, description) VALUES (?, ?, ?)");
foreach ($defaultSettings as $setting) {
$stmt->execute($setting);
}
echo "✅ Add settings table - წარმატებით შესრულდა\n";
}
} catch (Exception $e) {
// Rollback SQL (არასავალდებულო)
$downSql = "DROP TABLE IF EXISTS system_settings";
if ($downSql) {
try {
$pdo->exec($downSql);
echo "⚠️ Rollback SQL შესრულდა\n";
} catch (Exception $rollbackError) {
echo "❌ Rollback შეცდომა: " . $rollbackError->getMessage() . "\n";
}
}
throw new Exception("Add settings table - შეცდომა: " . $e->getMessage());
}
?>
@@ -0,0 +1,32 @@
<?php
/**
* Migration: Add test column
* Version: 1.0.3
* Created: 2025-07-31 10:39:56
*/
try {
// განახლების SQL
$upSql = "ALTER TABLE users ADD COLUMN test_field VARCHAR(50) DEFAULT NULL";
if ($upSql) {
$pdo->exec($upSql);
echo "✅ Add test column - წარმატებით შესრულდა\n";
}
} catch (Exception $e) {
// Rollback SQL (არასავალდებულო)
$downSql = "";
if ($downSql) {
try {
$pdo->exec($downSql);
echo "⚠️ Rollback SQL შესრულდა\n";
} catch (Exception $rollbackError) {
echo "❌ Rollback შეცდომა: " . $rollbackError->getMessage() . "\n";
}
}
throw new Exception("Add test column - შეცდომა: " . $e->getMessage());
}
?>
@@ -0,0 +1,58 @@
<?php
/**
* Migration: Add SMTP settings table
* Version: 1.0.4
* Created: 2025-07-31 11:00:00
*/
try {
// SMTP settings ცხრილის შექმნა
$upSql = "CREATE TABLE smtp_settings (
id INT AUTO_INCREMENT PRIMARY KEY,
setting_key VARCHAR(100) NOT NULL UNIQUE,
setting_value TEXT,
description VARCHAR(255),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
)";
if ($upSql) {
$pdo->exec($upSql);
// Default SMTP settings-ების ჩასმა
$defaultSettings = [
['smtp_host', 'vps-7146dd3a.vps.ovh.ca', 'SMTP სერვერის მისამართი'],
['smtp_port', '465', 'SMTP პორტი'],
['smtp_secure', 'ssl', 'SMTP უსაფრთხოება (ssl/tls)'],
['smtp_auth', '1', 'SMTP ავტორიზაცია (0/1)'],
['smtp_username', 'noreply@selfhosting.ge', 'SMTP მომხმარებლის სახელი'],
['smtp_password', 'FSZtTIIIlubk', 'SMTP პაროლი'],
['smtp_from_email', 'noreply@selfhosting.ge', 'გამომგზავნის ელ.ფოსტა'],
['smtp_from_name', 'SelfHosting.ge', 'გამომგზავნის სახელი'],
['smtp_debug', '0', 'Debug რეჟიმი (0-2)']
];
$stmt = $pdo->prepare("INSERT INTO smtp_settings (setting_key, setting_value, description) VALUES (?, ?, ?)");
foreach ($defaultSettings as $setting) {
$stmt->execute($setting);
}
echo "✅ Add SMTP settings table - წარმატებით შესრულდა\n";
}
} catch (Exception $e) {
// Rollback SQL
$downSql = "DROP TABLE IF EXISTS smtp_settings";
if ($downSql) {
try {
$pdo->exec($downSql);
echo "⚠️ Rollback SQL შესრულდა\n";
} catch (Exception $rollbackError) {
echo "❌ Rollback შეცდომა: " . $rollbackError->getMessage() . "\n";
}
}
throw new Exception("Add SMTP settings table - შეცდომა: " . $e->getMessage());
}
?>
+199
View File
@@ -0,0 +1,199 @@
#!/usr/bin/env php
<?php
/**
* CLI Update Manager
* გამოყენება: php update_cli.php [command] [options]
*/
require_once __DIR__ . '/../includes/db.php';
require_once __DIR__ . '/UpdateManager.php';
class UpdateCLI {
private $updateManager;
public function __construct($pdo) {
$this->updateManager = new UpdateManager($pdo);
}
public function run($args) {
if (count($args) < 2) {
$this->showHelp();
return;
}
$command = $args[1];
switch ($command) {
case 'status':
$this->showStatus();
break;
case 'list':
$this->listUpdates();
break;
case 'update':
$version = $args[2] ?? null;
if ($version) {
$this->runUpdate($version);
} else {
$this->runAllUpdates();
}
break;
case 'create':
$this->createMigration($args);
break;
case 'history':
$this->showHistory();
break;
default:
echo "❌ უცნობი ბრძანება: $command\n";
$this->showHelp();
}
}
private function showStatus() {
$currentVersion = $this->updateManager->getCurrentVersion();
$availableUpdates = $this->updateManager->getAvailableUpdates();
echo "📊 სისტემის სტატუსი\n";
echo "==================\n";
echo "მიმდინარე ვერსია: $currentVersion\n";
echo "ხელმისაწვდომი განახლებები: " . count($availableUpdates) . "\n\n";
if (count($availableUpdates) > 0) {
echo "ხელმისაწვდომი განახლებები:\n";
foreach ($availableUpdates as $update) {
echo " - {$update['version']}: {$update['description']}\n";
}
} else {
echo "✅ ყველაფერი განახლებულია!\n";
}
}
private function listUpdates() {
$availableUpdates = $this->updateManager->getAvailableUpdates();
echo "📋 ხელმისაწვდომი განახლებები\n";
echo "============================\n";
if (empty($availableUpdates)) {
echo "ხელმისაწვდომი განახლებები არ არის.\n";
return;
}
foreach ($availableUpdates as $update) {
echo "ვერსია: {$update['version']}\n";
echo "აღწერა: {$update['description']}\n";
echo "ფაილი: {$update['filename']}\n";
echo "---\n";
}
}
private function runUpdate($version) {
echo "🚀 განახლების გაშვება: $version\n";
try {
$result = $this->updateManager->runUpdate($version);
echo "" . $result['message'] . "\n";
} catch (Exception $e) {
echo "❌ შეცდომა: " . $e->getMessage() . "\n";
exit(1);
}
}
private function runAllUpdates() {
echo "🚀 ყველა განახლების გაშვება\n";
try {
$results = $this->updateManager->runAllUpdates();
foreach ($results as $result) {
if ($result['success']) {
echo "" . $result['message'] . "\n";
} else {
echo "" . $result['message'] . "\n";
break;
}
}
} catch (Exception $e) {
echo "❌ შეცდომა: " . $e->getMessage() . "\n";
exit(1);
}
}
private function createMigration($args) {
if (count($args) < 5) {
echo "❌ არასაკმარისი პარამეტრები მიგრაციის შესაქმნელად\n";
echo "გამოყენება: php update_cli.php create <version> <description> <sql>\n";
return;
}
$version = $args[2];
$description = $args[3];
$sql = $args[4];
$rollbackSql = $args[5] ?? '';
try {
$result = $this->updateManager->createMigration($version, $description, $sql, $rollbackSql);
echo "" . $result['message'] . "\n";
} catch (Exception $e) {
echo "❌ შეცდომა: " . $e->getMessage() . "\n";
exit(1);
}
}
private function showHistory() {
$history = $this->updateManager->getUpdateHistory();
echo "📜 განახლებების ისტორია\n";
echo "========================\n";
if (empty($history)) {
echo "განახლებების ისტორია ცარიელია.\n";
return;
}
foreach ($history as $record) {
$status = [
'completed' => '✅',
'failed' => '❌',
'pending' => '⏳'
][$record['status']];
echo "{$status} {$record['version']} - {$record['description']}\n";
echo " თარიღი: {$record['executed_at']}\n";
echo " სტატუსი: {$record['status']}\n";
echo "---\n";
}
}
private function showHelp() {
echo "🔧 Update Manager CLI\n";
echo "=====================\n\n";
echo "ბრძანებები:\n";
echo " status - სისტემის სტატუსი\n";
echo " list - ხელმისაწვდომი განახლებების სია\n";
echo " update [version] - განახლების გაშვება (ყველას ან კონკრეტული ვერსია)\n";
echo " create <version> <description> <sql> [rollback_sql] - ახალი მიგრაციის შექმნა\n";
echo " history - განახლებების ისტორია\n\n";
echo "მაგალითები:\n";
echo " php update_cli.php status\n";
echo " php update_cli.php update\n";
echo " php update_cli.php update 1.0.1\n";
echo " php update_cli.php create 1.0.3 'Add new feature' 'ALTER TABLE...'\n";
}
}
// CLI გაშვება
if (php_sapi_name() === 'cli') {
try {
$cli = new UpdateCLI($pdo);
$cli->run($argv);
} catch (Exception $e) {
echo "❌ კრიტიკული შეცდომა: " . $e->getMessage() . "\n";
exit(1);
}
} else {
echo "ეს სკრიპტი მუშაობს მხოლოდ CLI-დან.\n";
exit(1);
}
?>