<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class AddSubscriptionPricing extends Migration
{
    public function up()
    {
        $this->forge->addColumn('rewarder_shop_subscriptions', [
            'base_price' => ['type' => 'DECIMAL', 'constraint' => '10,2', 'default' => 0, 'after' => 'subscription_id'],
            'tax_group_id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'null' => true, 'after' => 'base_price'],
            'tax_inclusive' => ['type' => 'TINYINT', 'constraint' => 1, 'default' => 0, 'after' => 'tax_group_id'],
            'tax_total' => ['type' => 'DECIMAL', 'constraint' => '10,2', 'default' => 0, 'after' => 'tax_inclusive'],
            'total_amount' => ['type' => 'DECIMAL', 'constraint' => '10,2', 'default' => 0, 'after' => 'tax_total'],
        ]);
    }

    public function down()
    {
        $this->forge->dropColumn('rewarder_shop_subscriptions', 'base_price');
        $this->forge->dropColumn('rewarder_shop_subscriptions', 'tax_group_id');
        $this->forge->dropColumn('rewarder_shop_subscriptions', 'tax_inclusive');
        $this->forge->dropColumn('rewarder_shop_subscriptions', 'tax_total');
        $this->forge->dropColumn('rewarder_shop_subscriptions', 'total_amount');
    }
}

