Esempio n. 1
0
        /// <summary>
        /// Update the DB version
        /// </summary>
        private async Task UpdateVersion(int version)
        {
            _Logger.LogTrace($"Updating version to {version}");
            using NpgsqlConnection conn = _DbHelper.Connection();
            using NpgsqlCommand cmd     = await _DbHelper.Command(conn, @"
                INSERT INTO metadata (name, value)
                    VALUES ('id', @ID)
                ON CONFLICT (name) DO
                    UPDATE SET value = @ID;
            ");

            cmd.Parameters.AddWithValue("@ID", version);

            await cmd.ExecuteNonQueryAsync();

            _Logger.LogTrace($"Updated version to {version}");
        }
Esempio n. 2
0
        public async Task Execute(IDbHelper helper)
        {
            using NpgsqlConnection conn = helper.Connection();
            using NpgsqlCommand cmd     = await helper.Command(conn, @"
                CREATE TABLE IF NOT EXISTS metadata (
                    name varchar NOT NULL PRIMARY KEY,
                    value varchar NOT NULL
                );
            ");

            await cmd.ExecuteNonQueryAsync();
        }
Esempio n. 3
0
        public async Task Execute(IDbHelper helper)
        {
            using NpgsqlConnection conn = helper.Connection();
            using NpgsqlCommand cmd     = await helper.Command(conn, @"
                CREATE TABLE IF NOT EXISTS ps_item (
                    ID int4 NOT NULL PRIMARY KEY,
                    name varchar NOT NULL,
                    type_id int4 NOT NULL,
                    category_id int4 NOT NULL,
                    faction_id int4 NOT NULL
                );
            ");

            await cmd.ExecuteNonQueryAsync();
        }