Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tIZrO-00FBL1-7u for pgsql-general@arkaria.postgresql.org; Tue, 03 Dec 2024 20:51:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tIZrL-00Cpnk-QN for pgsql-general@arkaria.postgresql.org; Tue, 03 Dec 2024 20:51:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tIZrK-00Cpnc-FF for pgsql-general@lists.postgresql.org; Tue, 03 Dec 2024 20:51:04 +0000 Received: from fhigh-b2-smtp.messagingengine.com ([202.12.124.153]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tIZrG-000tCY-7m for pgsql-general@lists.postgresql.org; Tue, 03 Dec 2024 20:51:02 +0000 Received: from phl-compute-05.internal (phl-compute-05.phl.internal [10.202.2.45]) by mailfhigh.stl.internal (Postfix) with ESMTP id 360B3254018B; Tue, 3 Dec 2024 15:50:56 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Tue, 03 Dec 2024 15:50:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1733259056; x=1733345456; bh=itUF4ezEbHGj1PczPVU7/09DOkOWsdMt7PeA+nPApCs=; b= GvSf8xsCu6Cui8fNrWy8SYlAEaIJtex0I642rJrzI2V1rSZoQIjHLFljdQJWwO4T T6TobA8T+S2BZUOBBhyszhtzfc0MKl9H6JLo41iJF/8P4wUMG8jMe2jCE8lz0lTf +nkhdk7BuHWANV+zkjoQ97UzyYN1AtkwJbgmd8/fFo2aO7NqgrjT+BCHK6bmO8fH CTHCz44VTE1pRQeovRPNp4RUTAcEThdR5KeznnPbPQgZv6asbxo5BJ+Ab34jqGLi pcaqAOcRZ5LM9u19xa8UFTVleKz87zjT5OwFmgiMeyACyy6f0uO3iME1OHqlLAbc DcgA4brIYjY1JqxmAzUmLQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1733259056; x=1733345456; bh=i tUF4ezEbHGj1PczPVU7/09DOkOWsdMt7PeA+nPApCs=; b=CeEJRXl2zJtmpvzsP /MZE7d4rZeqcALxnwrsHe8vWafqxNOpGDq46YbMR5ddSe0kc1BqX09+4QY2oLv1y YtPdqhaaYrdQRaZAC6rePFA8RfR/+5eM6Y+tWzS3tnWJhQOP8c+qFNG2SDGSzcmW iH/Of19d50He0AOfKtDYOpCoZVdNYQqYTsswxuASC7Fe/Nddk3+HgUYWPe79Y93W tWiBs5NhZSAHamntBPAFxy/5BbMw4YNL7ums2zc9F3YTKePHhATlet6y6ej3GTWb sYPTOL6yC6pfSt5TbhtWOM0/sCGtVZbafI1bYLMlQCMdhZlge8nawiP7+RFCvs0a /PuWQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrieefgdduuddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepkfffgggfuffvfhfhjggtgfesthejredttddvjeen ucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrse grkhhlrghvvghrrdgtohhmqeenucggtffrrghtthgvrhhnpeeftdffvdfghfelkeetvdek vedtgfffffffvdefffdvjeeuieelueetgffgteeigfenucffohhmrghinhepshhqihhttg hhrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhho mheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomhdpnhgspghrtghpth htohepfedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepuhhtkhgrrhhshhhsrghs mhhithesghhmrghilhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhgvghnvghrrghlse hpohhsthhgrhgvshhqlhdrohhrghdprhgtphhtthhopehpghhsqhhlqdhgvghnvghrrghl sehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 3 Dec 2024 15:50:54 -0500 (EST) Message-ID: Date: Tue, 3 Dec 2024 12:50:54 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Best Practices for Managing Schema Changes Dynamically with libpq To: Sasmit Utkarsh , pgsql-general , pgsql-general@lists.postgresql.org References: Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 12/3/24 09:43, Sasmit Utkarsh wrote: > Dear PostgreSQL Community Team, > > I am working on a project that uses libpq along with C language to > interact with PostgreSQL, and we face challenges with managing schema > changes dynamically in production while avoiding downtime. Specifically, > we need guidance on handling table structure changes/additions without > tightly coupling these changes to application updates. > > *Current Approach:* > Schema changes are deployed first, followed by application updates to > align with the new structure. > > *Challenges:* > Ensuring application stability during the transitional phase when the > schema and code are not fully in sync. > Handling table structure changes (e.g., adding new columns) dynamically > without requiring immediate code changes. > > *Questions:* > Are there recommended best practices for managing such schema changes > with libpq? I use Sqitch(https://sqitch.org/). You have to squint but it is libpq, of a sort, as it uses psql to do its changes. > How can we efficiently handle table additions/updates while keeping the > application and database in sync dynamically? There is way too many variations that enter into the above to give a complete concrete answer in anything less then a short book. My general rule for this is to create a map of the process in outline form. Personally I still think better on paper and I pull out a legal pad and pencil and write out a work flow that goes from where I am to where I want to be. This starts with the 10000 foot view that I then drill down in to get the specific actions. I use a pencil as the drill down process often uncovers flaws in the 10000 foot view. This by the way was a method my 7th grade math teacher taught the class back way back when. > > I would appreciate any guidance, patterns, or examples that can help us > implement a robust solution. > > Thank you for your time and support! > > Regards, > Sasmit Utkarsh > +91-7674022625 -- Adrian Klaver adrian.klaver@aklaver.com