First Commit
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SysCMS - Content Management System
|
||||
*
|
||||
* Copyright (c) 2026 Marco Costa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Marco Costa
|
||||
* Email: contato@syspanel.com.br
|
||||
* Project: SysCMS
|
||||
*
|
||||
* This software is licensed, not sold.
|
||||
* Permission is granted to use this software
|
||||
* subject to the terms of the SysCMS Commercial License.
|
||||
*
|
||||
* Redistribution, sublicensing, resale, or
|
||||
* disclosure of this software, in whole or in part,
|
||||
* is strictly prohibited without prior written permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Migration: Create Notes Subjects Table and Update Notes Table
|
||||
*/
|
||||
class CreateNotesSubjectsTable
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// Create subjects table
|
||||
if (!Capsule::schema()->hasTable('notes_subjects')) {
|
||||
Capsule::schema()->create('notes_subjects', function (Blueprint $table) {
|
||||
$table->id('subjects_id');
|
||||
$table->unsignedBigInteger('subjects_idbus')->nullable();
|
||||
$table->unsignedBigInteger('subjects_iduser')->nullable();
|
||||
$table->string('subjects_name');
|
||||
$table->string('subjects_color')->default('#6c757d');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('subjects_idbus');
|
||||
$table->index('subjects_iduser');
|
||||
});
|
||||
}
|
||||
|
||||
// Update notes table to use subject_id
|
||||
if (Capsule::schema()->hasTable('notes')) {
|
||||
Capsule::schema()->table('notes', function (Blueprint $table) {
|
||||
if (!Capsule::schema()->hasColumn('notes', 'notes_subject_id')) {
|
||||
$table->unsignedBigInteger('notes_subject_id')->nullable()->after('notes_type');
|
||||
$table->index('notes_subject_id');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
if (Capsule::schema()->hasTable('notes')) {
|
||||
Capsule::schema()->table('notes', function (Blueprint $table) {
|
||||
if (Capsule::schema()->hasColumn('notes', 'notes_subject_id')) {
|
||||
$table->dropColumn('notes_subject_id');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Capsule::schema()->dropIfExists('notes_subjects');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user