Recently I wanted use the Fluent migrator for seeding my postgres database, which was running as a docker container. I basically had a table User, which had a primary key of type UUID that needs to be auto-generated. My migration code looked as follows. Create.Table(User.TABLE_NAME) .WithColumn("id").AsGuid().NotNullable().WithDefaultValue(SystemMethods.NewGuid).PrimaryKey() .WithColumn("username").AsString().NotNullable() .WithColumn("password").AsString().NotNullable(); The above code would essentially turn out as the following postgres sql. … Continue reading Install Extensions in Postgres Docker container
Category: Database
Create Mongo Replicaset using Docker Compose
In this blog post, we will attempt to create MongoDb replicaset using docker compose. A replica set in mongodb is a group of mongod instances which maintains the same set of data. This enables applications to work despite one of the db servers going down. At every instance, there wil be only and only ONE primary node. Rest of the … Continue reading Create Mongo Replicaset using Docker Compose
Seed Postgres Database with FluentMigrator
In this blog post, we will address how to seed your Postgres Database when using FluentMigrator. In the example context, we have a Postges Database running on a docker container, and have a Web Api connecting to the database using Dapper. Dapper is a micro-orm, and while it is pretty good in what is does, … Continue reading Seed Postgres Database with FluentMigrator
MongoDb, Docker and Compass
The other day I struggled a bit in setting up MongoDb in a docker container and then connecting it with Compass - the MongoDb client. That's when I thought I would document the knowledge here so that anyone else who run into similar problems could look into it (and also in case I forget later, … Continue reading MongoDb, Docker and Compass
The Last Non-Null Value Problem
I recently came across a problem with a query in Sql Server which I thought about sharing in my blog as this could be useful to many. Following is a summary of the problem. A similar problem is discussed in the Blog Entry First Non Null Puzzle by Itzik Ben-Gan. But my own problem had a little … Continue reading The Last Non-Null Value Problem
Cheat Code for Database Meta information : PostgreSql
In an earlier post we looked at the Queries for Sql Server for retrieving meta information. In this post, we will look at the PostgresSql version. Get All Views SELECT table_name, view_definition FROM information_schema.VIEWS WHERE table_schema = ANY ( Current_schemas(FALSE) ); Get All Tables SELECT table_name FROM information_schema.TABLES WHERE table_schema = ANY ( Current_schemas(FALSE) ) Get All … Continue reading Cheat Code for Database Meta information : PostgreSql
Cheat Code for Database Meta information : Sql Server
This post acts as a quick reference/Cheat code for anyone who would like to query the meta information about different entities in a database using Sql Server. Get all Views in the Database SELECT NAME, Object_definition (Object_id(NAME)) FROM sys.views Get All Tables in the Database SELECT NAME FROM sys.tables Get all columns from a table … Continue reading Cheat Code for Database Meta information : Sql Server
MongoDb 002 : CRUD – Part 1
We will continue with our exploration of MongoDb in this second part of tutorial, working our CRUD examples. Let's beging with the 'C'. In order to create a document, you would need to use, as you can guess, the Insert command. Notice that we are using a new collection named subject here. MongoDb would automatically … Continue reading MongoDb 002 : CRUD – Part 1
MongoDb 001 : Basic Commands
Before we actually get into MongoDb, let's begin by importing a Test Db. You can access the JSON file here. Once you have downloaded the file, use following command to import the document into mongodb. Let's break it down, the command tells you to import a file students.json into a database called testdb and collection … Continue reading MongoDb 001 : Basic Commands
MongoDb : Beginners Guide
MongoDb is definitely fascinating, and it is here to stay, there is no doubts about it. Here is my attempt to put together a small series of tutorial for beginners. Probably sometime down the line, I will put together a beginners guide on some other NoSql Db as well, but here is one for MongoDb, … Continue reading MongoDb : Beginners Guide