Ir para conteúdo
  • 0
Entre para seguir isso  
shumagoraa

Website Erro ao colocar query na database

Pergunta

shumagoraa    0
shumagoraa

Antes de fazer a sua pergunta, tenha certeza de ter lido as regras da seção e o guia abaixo:

https://forums.otserv.com.br/index.php?/forums/topic/168583-regras-da-seção/

https://forums.otserv.com.br/index.php?/forums/topic/165121-como-fazer-uma-pergunta-ou-o-grande-guia-do-usuário-com-dúvidas/

Descreva em algumas palavras a base utilizada. (Nome do servidor / Nome do cliente / Nome do website / etc.).

Ex: The Forgotten Server 1.3, Versão: 10.98.

Base:

 

Qual é a sua pergunta?

Tento executar a db.query da pasta migrations otservbr-global 12.x porém ele não executa, da um erro na distro e ao tentar executar direto na database tbm da erro. Estou usando a database compatível com o site gesior disponibilizado no site forums.otserv.com.br

 

Você tem o código disponível? Se tiver poste-o na caixa de código que está dentro do spoiler abaixo:

Spoiler

function onUpdateDatabase()
    print("> Updating database to version 3 (account refactor)")

    db.query([[
        LOCK TABLES
            players WRITE,
            account_bans WRITE,
            account_ban_history WRITE,
            account_viplist WRITE,
            store_history WRITE,
            accounts WRITE;
    ]])

    db.query([[
        ALTER TABLE `players`
            DROP FOREIGN KEY `players_account_fk`,
            MODIFY account_id int(11) UNSIGNED NOT NULL;
    ]])

    db.query([[
        ALTER TABLE `account_bans`
            DROP PRIMARY KEY,
            DROP FOREIGN KEY `account_bans_account_fk`,
            MODIFY `account_id` int(11) UNSIGNED NOT NULL;
    ]])

    db.query([[
        ALTER TABLE `account_ban_history`
            DROP FOREIGN KEY `account_bans_history_account_fk`,
            MODIFY `account_id` int(11) UNSIGNED NOT NULL;
    ]])

    db.query([[
        ALTER TABLE `account_viplist`
            DROP INDEX `account_viplist_unique`,
            DROP FOREIGN KEY `account_viplist_account_fk`,
            MODIFY `account_id` int(11) UNSIGNED NOT NULL;
    ]])

    db.query([[
        ALTER TABLE `store_history`
            DROP FOREIGN KEY `store_history_account_fk`,
            MODIFY `account_id` int(11) UNSIGNED NOT NULL;
    ]])

    db.query([[
        ALTER TABLE `accounts`
            MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
            MODIFY `type` tinyint(1) UNSIGNED NOT NULL DEFAULT '1',
            MODIFY `coins` int(12) UNSIGNED NOT NULL DEFAULT '0',
            MODIFY `creation` int(11) UNSIGNED NOT NULL DEFAULT '0';
    ]])

    db.query([[
        ALTER TABLE `players`
            ADD CONSTRAINT `players_account_fk`
            FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`)
                ON DELETE CASCADE;
    ]])

    db.query([[
        ALTER TABLE `account_bans`
            ADD CONSTRAINT `account_bans_pk` PRIMARY KEY (`account_id`),
            ADD CONSTRAINT `account_bans_account_fk`
            FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`)
                ON DELETE CASCADE
                ON UPDATE CASCADE;
    ]])

    db.query([[
        ALTER TABLE `account_ban_history`
            ADD CONSTRAINT `account_bans_history_account_fk`
            FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`)
                ON DELETE CASCADE
                ON UPDATE CASCADE;
    ]])

    db.query([[
        ALTER TABLE `account_viplist`
            ADD CONSTRAINT `account_viplist_unique` UNIQUE (`account_id`, `player_id`),
            ADD CONSTRAINT `account_viplist_account_fk`
                FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`)
                    ON DELETE CASCADE;
    ]])

    db.query([[
        ALTER TABLE `store_history`
            ADD CONSTRAINT `store_history_account_fk`
                FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`)
                    ON DELETE CASCADE;
    ]])

    db.query([[
        UNLOCK TABLES;
    ]])

    db.query([[
        CREATE TABLE IF NOT EXISTS `coins_transactions` (
                `id`          int(11)       UNSIGNED NOT NULL AUTO_INCREMENT,
                `account_id`  int(11)       UNSIGNED NOT NULL,
                `type`        tinyint(1)    UNSIGNED NOT NULL,
                `amount`      int(12)       UNSIGNED NOT NULL,
                `description` varchar(3500) NOT NULL,
                `timestamp`   timestamp     DEFAULT CURRENT_TIMESTAMP,
                INDEX `account_id` (`account_id`),
                CONSTRAINT `coins_transactions_pk` PRIMARY KEY (`id`),
                CONSTRAINT `coins_transactions_account_fk`
                    FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`)
                        ON DELETE CASCADE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
    ]])

    return true
end
 

 

Você tem alguma imagem que possa auxiliar no problema? Se sim, anexe-a dentro do spoiler abaixo:

Spoiler

Sem título.png

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

1 resposta a esta questão

Recommended Posts

  • 0
Majesty    1755
Majesty

Você não precisa executar as querys que estão na pasta migrations, o banco de dados que está para download com o gesior já está adaptado até a migração 3 e o servidor faz o restante das migrações (4 em diante). 

 

Compartilhar este post


Link para o post
Compartilhar em outros sites
Visitante
Este tópico está impedido de receber novos posts.
Entre para seguir isso  

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×