1
0
mirror of https://bitbucket.org/anguist/ntpa synced 2025-10-05 10:30:56 +00:00

Fix database issues

This commit is contained in:
Carsten Larsen
2016-12-10 12:25:20 +01:00
parent 604f3c43e1
commit 8bf5f298a4
4 changed files with 49 additions and 5 deletions

View File

@ -1,3 +1,8 @@
v0.7.6
- Corrected faulty version numbers in v0.7.5
- Improved logging of database errors
- Sanitized default configuration
v0.7.5 v0.7.5
- Change build script to autotools - Change build script to autotools
- Updated PostgreSQL data provider to v3.1.9 - Updated PostgreSQL data provider to v3.1.9
@ -41,4 +46,4 @@ v0.7.0
- Updated jQuery to v2.2.4 - Updated jQuery to v2.2.4
Changes prior to 0.7.0 is not recorded. Changes prior to 0.7.0 are not recorded.

25
DATABASE Normal file
View File

@ -0,0 +1,25 @@
Manually setup a MySQL user on localhost
----------------------------------------
Log in as root:
# mysql -uroot -p
Create database and grant privileges:
# CREATE DATABASE ntpa;
# CREATE USER 'ntpau'@'localhost' IDENTIFIED BY 'password';
# GRANT ALL PRIVILEGES ON ntpa . * TO 'ntpau'@'localhost';
# FLUSH PRIVILEGES;
Manually setup a MySQL user on a foreign host
---------------------------------------------
Log in as root:
# mysql -uroot -p
Create database and grant privileges:
# CREATE DATABASE ntpa;
# CREATE USER 'ntpau'@'192.168.1.1' IDENTIFIED BY 'password';
# GRANT ALL PRIVILEGES ON ntpa . * TO 'ntpau'@'192.168.1.1';
# FLUSH PRIVILEGES;

View File

@ -53,20 +53,23 @@ namespace Ntp.Analyzer.Data.Log
internal static void DeleteError(this LogBase log, string table, Exception e) internal static void DeleteError(this LogBase log, string table, Exception e)
{ {
log.WriteLine($"Error while deleting from table {table}: {e.Message}", Severity.Error); log.WriteLine($"Error while deleting from table {table}: {e.Message}", Severity.Warn);
log.WriteLine(e); log.WriteLine(e);
Advice(log);
} }
internal static void InsertError(this LogBase log, string table, Exception e) internal static void InsertError(this LogBase log, string table, Exception e)
{ {
log.WriteLine($"Error while inserting into table {table}: {e.Message}", Severity.Error); log.WriteLine($"Error while inserting into table {table}: {e.Message}", Severity.Warn);
log.WriteLine(e); log.WriteLine(e);
Advice(log);
} }
internal static void ReadError(this LogBase log, string table, Exception e) internal static void ReadError(this LogBase log, string table, Exception e)
{ {
log.WriteLine($"Error while reading from table {table}: {e.Message}", Severity.Error); log.WriteLine($"Error while reading from table {table}: {e.Message}", Severity.Warn);
log.WriteLine(e); log.WriteLine(e);
Advice(log);
} }
internal static void TableExists(this LogBase log, string table) internal static void TableExists(this LogBase log, string table)
@ -78,8 +81,14 @@ namespace Ntp.Analyzer.Data.Log
internal static void UpdateError(this LogBase log, string table, Exception e) internal static void UpdateError(this LogBase log, string table, Exception e)
{ {
log.WriteLine($"Error while updating table {table}: {e.Message}", Severity.Error); log.WriteLine($"Error while updating table {table}: {e.Message}", Severity.Warn);
log.WriteLine(e); log.WriteLine(e);
Advice(log);
}
private static void Advice(LogBase log)
{
log.WriteLine($"Try setting 'Create Yes' in configuration.", Severity.Notice);
} }
} }
} }

View File

@ -109,6 +109,11 @@ namespace Ntp.Data.Log
internal static void SchemaVersionError(this LogBase log, int database, int application) internal static void SchemaVersionError(this LogBase log, int database, int application)
{ {
if (database == -1)
{
log.WriteLine("Database version is -1. Did you set 'Create Yes' in configuration ?", Severity.Notice);
}
log.WriteLine( log.WriteLine(
$"Application version is {application} but database version is {database}.", $"Application version is {application} but database version is {database}.",
Severity.Error); Severity.Error);