#!/usr/bin/env bash

# Copyright © 2012-2026 ScriptFanix
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# A copy of the GNU General Public License v3 is includded in the LICENSE file
# at the root of the project.

upgradedatabase_2_3() {
	local	data		\
		datas		\
		id		\
                destination
        echo "Upgrading database to version 3... (backup is $database.bak_v2)"
        cp "$database" "$database.bak_v2"
        # Add 'enabled' flag to destinations so individual destinations can be disabled
        echo 'ALTER TABLE destinations ADD COLUMN enabled INTEGER DEFAULT 1;' >&3
        # Enable all existing destinations (preserve old behaviour where all were active)
        Update destinations enabled 1 <<< "1 = 1"

        Update atom version 3 <<<"1 = 1"
}
