EnsureExists now calls EnsureTableStructure directly
It occurs to me that copypasting code is bad
This commit is contained in:
parent
f4564b88e9
commit
d82851faf3
1 changed files with 1 additions and 13 deletions
|
|
@ -79,19 +79,7 @@ namespace TShockAPI.DB
|
||||||
[Obsolete("This method will be replaced by EnsureTableExists.")]
|
[Obsolete("This method will be replaced by EnsureTableExists.")]
|
||||||
public void EnsureExists(SqlTable table)
|
public void EnsureExists(SqlTable table)
|
||||||
{
|
{
|
||||||
var columns = GetColumns(table);
|
EnsureTableStructure(table);
|
||||||
if (columns.Count > 0)
|
|
||||||
{
|
|
||||||
if (!table.Columns.All(c => columns.Contains(c.Name)) || !columns.All(c => table.Columns.Any(c2 => c2.Name == c)))
|
|
||||||
{
|
|
||||||
var from = new SqlTable(table.Name, columns.Select(s => new SqlColumn(s, MySqlDbType.String)).ToList());
|
|
||||||
database.Query(creator.AlterTable(from, table));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
database.Query(creator.CreateTable(table));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<string> GetColumns(SqlTable table)
|
public List<string> GetColumns(SqlTable table)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue