added import function for migration tool.

This commit is contained in:
DESKTOP-GENO133\IvanPlex
2024-02-09 13:34:10 -07:00
parent c4dc81e4bc
commit 32e58e6280
19 changed files with 473 additions and 18 deletions

View File

@@ -18,7 +18,7 @@ namespace CarCareTracker.External.Implementations
{
pgDataSource.Open();
//create table if not exist.
string initCMD = $"CREATE TABLE IF NOT EXISTS app.{tableName} (id INT GENERATED ALWAYS AS IDENTITY primary key, vehicleId INT not null, data jsonb not null)";
string initCMD = $"CREATE TABLE IF NOT EXISTS app.{tableName} (id INT GENERATED BY DEFAULT AS IDENTITY primary key, vehicleId INT not null, data jsonb not null)";
using (var ctext = new NpgsqlCommand(initCMD, pgDataSource))
{
ctext.ExecuteNonQuery();

View File

@@ -18,7 +18,7 @@ namespace CarCareTracker.External.Implementations
{
pgDataSource.Open();
//create table if not exist.
string initCMD = $"CREATE TABLE IF NOT EXISTS app.{tableName} (id INT GENERATED ALWAYS AS IDENTITY primary key, vehicleId INT not null, data jsonb not null)";
string initCMD = $"CREATE TABLE IF NOT EXISTS app.{tableName} (id INT GENERATED BY DEFAULT AS IDENTITY primary key, vehicleId INT not null, data jsonb not null)";
using (var ctext = new NpgsqlCommand(initCMD, pgDataSource))
{
ctext.ExecuteNonQuery();

View File

@@ -18,7 +18,7 @@ namespace CarCareTracker.External.Implementations
{
pgDataSource.Open();
//create table if not exist.
string initCMD = $"CREATE TABLE IF NOT EXISTS app.{tableName} (id INT GENERATED ALWAYS AS IDENTITY primary key, vehicleId INT not null, data jsonb not null)";
string initCMD = $"CREATE TABLE IF NOT EXISTS app.{tableName} (id INT GENERATED BY DEFAULT AS IDENTITY primary key, vehicleId INT not null, data jsonb not null)";
using (var ctext = new NpgsqlCommand(initCMD, pgDataSource))
{
ctext.ExecuteNonQuery();

View File

@@ -18,7 +18,7 @@ namespace CarCareTracker.External.Implementations
{
pgDataSource.Open();
//create table if not exist.
string initCMD = $"CREATE TABLE IF NOT EXISTS app.{tableName} (id INT GENERATED ALWAYS AS IDENTITY primary key, vehicleId INT not null, data jsonb not null)";
string initCMD = $"CREATE TABLE IF NOT EXISTS app.{tableName} (id INT GENERATED BY DEFAULT AS IDENTITY primary key, vehicleId INT not null, data jsonb not null)";
using (var ctext = new NpgsqlCommand(initCMD, pgDataSource))
{
ctext.ExecuteNonQuery();

View File

@@ -18,7 +18,7 @@ namespace CarCareTracker.External.Implementations
{
pgDataSource.Open();
//create table if not exist.
string initCMD = $"CREATE TABLE IF NOT EXISTS app.{tableName} (id INT GENERATED ALWAYS AS IDENTITY primary key, vehicleId INT not null, data jsonb not null)";
string initCMD = $"CREATE TABLE IF NOT EXISTS app.{tableName} (id INT GENERATED BY DEFAULT AS IDENTITY primary key, vehicleId INT not null, data jsonb not null)";
using (var ctext = new NpgsqlCommand(initCMD, pgDataSource))
{
ctext.ExecuteNonQuery();

View File

@@ -18,7 +18,7 @@ namespace CarCareTracker.External.Implementations
{
pgDataSource.Open();
//create table if not exist.
string initCMD = $"CREATE TABLE IF NOT EXISTS app.{tableName} (id INT GENERATED ALWAYS AS IDENTITY primary key, vehicleId INT not null, data jsonb not null)";
string initCMD = $"CREATE TABLE IF NOT EXISTS app.{tableName} (id INT GENERATED BY DEFAULT AS IDENTITY primary key, vehicleId INT not null, data jsonb not null)";
using (var ctext = new NpgsqlCommand(initCMD, pgDataSource))
{
ctext.ExecuteNonQuery();

View File

@@ -18,7 +18,7 @@ namespace CarCareTracker.External.Implementations
{
pgDataSource.Open();
//create table if not exist.
string initCMD = $"CREATE TABLE IF NOT EXISTS app.{tableName} (id INT GENERATED ALWAYS AS IDENTITY primary key, vehicleId INT not null, data jsonb not null)";
string initCMD = $"CREATE TABLE IF NOT EXISTS app.{tableName} (id INT GENERATED BY DEFAULT AS IDENTITY primary key, vehicleId INT not null, data jsonb not null)";
using (var ctext = new NpgsqlCommand(initCMD, pgDataSource))
{
ctext.ExecuteNonQuery();

View File

@@ -18,7 +18,7 @@ namespace CarCareTracker.External.Implementations
{
pgDataSource.Open();
//create table if not exist.
string initCMD = $"CREATE TABLE IF NOT EXISTS app.{tableName} (id INT GENERATED ALWAYS AS IDENTITY primary key, vehicleId INT not null, data jsonb not null)";
string initCMD = $"CREATE TABLE IF NOT EXISTS app.{tableName} (id INT GENERATED BY DEFAULT AS IDENTITY primary key, vehicleId INT not null, data jsonb not null)";
using (var ctext = new NpgsqlCommand(initCMD, pgDataSource))
{
ctext.ExecuteNonQuery();

View File

@@ -18,7 +18,7 @@ namespace CarCareTracker.External.Implementations
{
pgDataSource.Open();
//create table if not exist.
string initCMD = $"CREATE TABLE IF NOT EXISTS app.{tableName} (id INT GENERATED ALWAYS AS IDENTITY primary key, vehicleId INT not null, data jsonb not null)";
string initCMD = $"CREATE TABLE IF NOT EXISTS app.{tableName} (id INT GENERATED BY DEFAULT AS IDENTITY primary key, vehicleId INT not null, data jsonb not null)";
using (var ctext = new NpgsqlCommand(initCMD, pgDataSource))
{
ctext.ExecuteNonQuery();

View File

@@ -18,7 +18,7 @@ namespace CarCareTracker.External.Implementations
{
pgDataSource.Open();
//create table if not exist.
string initCMD = $"CREATE TABLE IF NOT EXISTS app.{tableName} (id INT GENERATED ALWAYS AS IDENTITY primary key, vehicleId INT not null, data jsonb not null)";
string initCMD = $"CREATE TABLE IF NOT EXISTS app.{tableName} (id INT GENERATED BY DEFAULT AS IDENTITY primary key, vehicleId INT not null, data jsonb not null)";
using (var ctext = new NpgsqlCommand(initCMD, pgDataSource))
{
ctext.ExecuteNonQuery();

View File

@@ -17,7 +17,7 @@ namespace CarCareTracker.External.Implementations
{
pgDataSource.Open();
//create table if not exist.
string initCMD = $"CREATE TABLE IF NOT EXISTS app.{tableName} (id INT GENERATED ALWAYS AS IDENTITY primary key, body TEXT not null, emailaddress TEXT not null)";
string initCMD = $"CREATE TABLE IF NOT EXISTS app.{tableName} (id INT GENERATED BY DEFAULT AS IDENTITY primary key, body TEXT not null, emailaddress TEXT not null)";
using (var ctext = new NpgsqlCommand(initCMD, pgDataSource))
{
ctext.ExecuteNonQuery();

View File

@@ -18,7 +18,7 @@ namespace CarCareTracker.External.Implementations
{
pgDataSource.Open();
//create table if not exist.
string initCMD = $"CREATE TABLE IF NOT EXISTS app.{tableName} (id INT GENERATED ALWAYS AS IDENTITY primary key, vehicleId INT not null, data jsonb not null)";
string initCMD = $"CREATE TABLE IF NOT EXISTS app.{tableName} (id INT GENERATED BY DEFAULT AS IDENTITY primary key, vehicleId INT not null, data jsonb not null)";
using (var ctext = new NpgsqlCommand(initCMD, pgDataSource))
{
ctext.ExecuteNonQuery();

View File

@@ -34,7 +34,7 @@ namespace CarCareTracker.External.Implementations
try
{
string cmd = $"SELECT data FROM app.{tableName} WHERE id = @id";
var result = new UserConfigData();
UserConfigData result = null;
using (var ctext = new NpgsqlCommand(cmd, pgDataSource))
{
ctext.Parameters.AddWithValue("id", userId);
@@ -45,7 +45,6 @@ namespace CarCareTracker.External.Implementations
result = userConfig;
}
}
if (result.UserConfig == null) { return null; }
return result;
}
catch (Exception ex)
@@ -59,7 +58,7 @@ namespace CarCareTracker.External.Implementations
var existingRecord = GetUserConfig(userConfigData.Id);
try
{
if (existingRecord == null || existingRecord.Id == default)
if (existingRecord == null)
{
string cmd = $"INSERT INTO app.{tableName} (id, data) VALUES(@id, CAST(@data AS jsonb))";
using (var ctext = new NpgsqlCommand(cmd, pgDataSource))

View File

@@ -17,7 +17,7 @@ namespace CarCareTracker.External.Implementations
{
pgDataSource.Open();
//create table if not exist.
string initCMD = $"CREATE TABLE IF NOT EXISTS app.{tableName} (id INT GENERATED ALWAYS AS IDENTITY primary key, username TEXT not null, emailaddress TEXT not null, password TEXT not null, isadmin BOOLEAN)";
string initCMD = $"CREATE TABLE IF NOT EXISTS app.{tableName} (id INT GENERATED BY DEFAULT AS IDENTITY primary key, username TEXT not null, emailaddress TEXT not null, password TEXT not null, isadmin BOOLEAN)";
using (var ctext = new NpgsqlCommand(initCMD, pgDataSource))
{
ctext.ExecuteNonQuery();

View File

@@ -18,7 +18,7 @@ namespace CarCareTracker.External.Implementations
{
pgDataSource.Open();
//create table if not exist.
string initCMD = $"CREATE TABLE IF NOT EXISTS app.{tableName} (id INT GENERATED ALWAYS AS IDENTITY primary key, data jsonb not null)";
string initCMD = $"CREATE TABLE IF NOT EXISTS app.{tableName} (id INT GENERATED BY DEFAULT AS IDENTITY primary key, data jsonb not null)";
using (var ctext = new NpgsqlCommand(initCMD, pgDataSource))
{
ctext.ExecuteNonQuery();