Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kQ9wh-0000DG-UK for pgsql-general@arkaria.postgresql.org; Wed, 07 Oct 2020 13:57:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kQ9wf-0003wh-Ca for pgsql-general@arkaria.postgresql.org; Wed, 07 Oct 2020 13:57:29 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kQ9wf-0003wY-4K for pgsql-general@lists.postgresql.org; Wed, 07 Oct 2020 13:57:29 +0000 Received: from [64.147.123.20] (helo=wout4-smtp.messagingengine.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kQ9wc-00029J-Ch for pgsql-general@lists.postgresql.org; Wed, 07 Oct 2020 13:57:28 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id B1EFAAB0; Wed, 7 Oct 2020 09:57:14 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 07 Oct 2020 09:57:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=p ymiZJRq7ejumty6AnumVUyIiAr1TZp7nzqdEvFe2SQ=; b=cp66OQ93wijaFVkdR txzx2gTSXOZVZKT+Nj/HrsVJAFdM98PG9w3pvwxocXFcidibavx7CPSbxduYZAWK pN9Qvtsr2FQWSdksblKOozbDv0Q4XqB5VkAxodhDFUGfOKngiPPONdmaVAxlbGJW bsnHbgVfVE/dw79nx/FqQdNpRJBO0//BmgEDO92V0i+2ldwaGekLKUCInesC4s10 5ZYJkNjsa9/QzBjtgIisIE+lHOFI9O7mltYIYmMp8G+6Px+I7wqmxqGFRF8wppe0 JBSQ/4CDZQCYWcrPKc1Tlkutacg1dezJ0ICw+2FM1IvbU/svSbByeiegLOzKuyIZ PQdrw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=pymiZJRq7ejumty6AnumVUyIiAr1TZp7nzqdEvFe2 SQ=; b=HzZaysAj+AyvlHHDjZQVyO6RRunOKJPaPyb+Zt6+UUFAmbp0EkW+FnHBH f/xBLx9HIl8hulECQqLLTGZbUFgCGQ2lRQDwQWZYzBSuoPstsnYu+TBs9bCsQq3N DvBWpE4H9tDyCTzJtekTRDLJYrO10w1PQI65dZ2XA65s4GGdV+grZ5UTaPMPFzGO xD7p90eBoJSYLIYZkWX4obzIZSE2SjWUKAP8F8DmO1mSPLTjE9L4t0IS1BJPOrYb UYRrmJG6mUpK5tMb8rG8HY2o9rUgZxnB9dohSJCyVrc84/hmxYKV0z0GOAMES0OF sVrwvsb8NpXlb+vO1h3xw7zz8Jdpg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrgeeigdejvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefuvfhfhffkffgfgggjtgfgsehtjeertddtfeejnecuhfhrohhmpeetughrihgr nhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh eqnecuggftrfgrthhtvghrnhepteejvdetffejuedvleeifeefheeutdfhgfdvhffhhfek vdduveegvdejudefgfevnecukfhppeejhedrudejvddrhedrvdefudenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghv vghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Received: from [192.168.1.3] (75-172-5-231.tukw.qwest.net [75.172.5.231]) by mail.messagingengine.com (Postfix) with ESMTPA id A41283064610; Wed, 7 Oct 2020 09:57:13 -0400 (EDT) Subject: Re: How to migrate column type from uuid to serial To: Hemil Ruparel , pgsql-general@lists.postgresql.org References: From: Adrian Klaver Message-ID: Date: Wed, 7 Oct 2020 06:57:13 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 64.147.123.20 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 10/7/20 5:48 AM, Hemil Ruparel wrote: > I was integrating a payment gateway for my app when I noticed its > maximum length of customer id string is 32. SIze of UUID is 36 (32 > characters and 4 dashes). So I want to change the type of customer id to > serial. The problem is by now, the column is being used at many places. > How to migrate the column to serial without dropping the data? Changing the size of the column is not an option? Your description of the customer id column above is somewhat confusing to me. Is the id actually stored as a UUID? Why is the max length an issue? If you where to migrate I would say create an independent serial/identity column. Then point the dependent objects at that. After all have been converted drop the old column. -- Adrian Klaver adrian.klaver@aklaver.com