PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV Mobile 2024 → Sqlite version control - Controle Versao Sqlite
Sqlite version control - Controle Versao Sqlite
Débuté par adrianoboller, 18 nov. 2014 13:50 - Aucune réponse
Membre enregistré
3 655 messages
Popularité : +175 (223 votes)
Posté le 18 novembre 2014 - 13:50
Procedure DB_ControleVersaoSql()

//VERSAO ATUAL A VERIFICAR
VersaoNova is string = "3.0" // <---- aumente a versao para excluir a base antiga antes de publicar no google play

//Path
//sBasePath is string = ""
sPathArquivoIni is string = ""

//Connect
sDatabaseName is string = "FaixaVermelha.db"
sNomeArquivoIni is string = "DB.ini"

IF InSimulatorMode() = False
gsBasePath = gsAppDir + ["/DB/"] + sDatabaseName
sPathArquivoIni = gsAppDir + ["/DB/"] + sNomeArquivoIni
ELSE
gsBasePath = gsAppDir + ["\DB\"] + sDatabaseName
sPathArquivoIni = gsAppDir + ["\DB\"] + sNomeArquivoIni
END


//Se nao tem o arquivo ini
IF fFileExist(sPathArquivoIni) = False AND fFileExist(gsBasePath) = True THEN

fDelete(gsBasePath)

INIWrite("BaseDados","Versao", VersaoNova, sPathArquivoIni)

//Se existe o ini e o banco verifique a versao
ELSE IF fFileExist(sPathArquivoIni) = True AND fFileExist(gsBasePath) = True THEN

//Se versao diferente exclua
VersaoExistente is string = INIRead("BaseDados","Versao","",sPathArquivoIni)
IF VersaoExistente <> VersaoNova THEN
fDelete(gsBasePath)
END

//Atualiza Arquivo ini
INIWrite("BaseDados","Versao", VersaoNova, sPathArquivoIni)

//Nao existe nada
ELSE IF fFileExist(sPathArquivoIni) = False AND fFileExist(gsBasePath) = False THEN

INIWrite("BaseDados","Versao", VersaoNova, sPathArquivoIni)

END

//Se Tiver ExcluirTudo = SIM
IF INIRead("BaseDados","ExcluirTudo","",sPathArquivoIni) = "SIM" THEN

fDelete(gsBasePath)
fDelete(sPathArquivoIni)
fRemoveDir(gsAppDir)

NextTitle("Atenção")
Info("Inicialize novamente o aplicativo.")

Close()

END