ARUNOX Framework

ARUNOX\Migrations\BaseMigration

Diese Dokumentation beschreibt die abstrakte Klasse Migrations\BaseMigration, die als Basisklasse für alle Migrationen im ARUNOX-Framework dient.

Einleitung

Die Klasse Migrations\BaseMigration definiert die grundlegende Struktur für Migrationen. Sie stellt die abstrakte Methode up() für die Implementierung von Migrationslogik und die optionale Methode down() für das Zurücksetzen bereit.

Strukturübersicht

Die Klasse Migrations\BaseMigration befindet sich im folgenden Verzeichnis:

library/ARUNOX/Migrations/BaseMigration.php

Voraussetzungen

Folgende Voraussetzungen müssen erfüllt sein, um die Klasse erfolgreich nutzen zu können:

Anwendung

So verwenden Sie die Klasse Migrations\BaseMigration als Grundlage für Ihre eigenen Migrationen:

Beispielmigration

namespace ARUNOX\Migrations;

class CreateUsersTable extends BaseMigration
{
    public function up(): void
    {
        $this->db()->query(<<execute();
    }

    public function down(): void
    {
        $this->db()->query("DROP TABLE IF EXISTS users")->execute();
    }
}
    

Sourcecode

Pfad: library/ARUNOX/Migrations/BaseMigration.php

<?php
	/**
	 * ARUNOX\Migrations\Migration
	 *
	 * Abstract base class for defining migrations in the ARUNOX Framework.
	 * Provides a consistent structure for the `up()` and optional `down()` methods.
	 *
	 * @version         1.0.0
	 * @author          Sparky
	 * @copyright       2025 ARUNOX
	 */
	
	namespace ARUNOX\Migrations;
	
	use ARUNOX\Core\Database;
	
	abstract class BaseMigration
	{
		/**
		 * Applies the migration logic.
		 */
		abstract public function up(): void;
		
		/**
		 * Reverts the migration logic (optional).
		 */
		public function down(): void
		{
			// Optional implementation for rollback logic
		}
		
		/**
		 * Provides access to the Database instance.
		 *
		 * @return Database
		 */
		protected function db(): Database
		{
			return Database::getInstance();
		}
	}