Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hRJjH-00019B-9u for pgsql-general@arkaria.postgresql.org; Thu, 16 May 2019 16:59:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hRJjE-0005Es-CK for pgsql-general@arkaria.postgresql.org; Thu, 16 May 2019 16:59:36 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hRJjD-0005Bk-RC for pgsql-general@lists.postgresql.org; Thu, 16 May 2019 16:59:36 +0000 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hRJjA-0003SB-IC for pgsql-general@lists.postgresql.org; Thu, 16 May 2019 16:59:34 +0000 Received: by mail-pg1-x529.google.com with SMTP id d30so1854215pgm.7 for ; Thu, 16 May 2019 09:59:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=illuminatedcomputing-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=fxakradHXFMEPvkT0xe7n1MvjA07iD3Xlj7rhy6xFHU=; b=LukdhnxEHEvOFevSag8MPy2DlkGAI4yHSEOpL+/dGszkJAjIe0TAe1WpMrGXymJjm4 LHf7uuaxN/vmS0nLiJNq7uUa8RuYeeJXvRhueVwH0PCExYhSsDajrGZMNBRqg2MZhMO1 PzfZGINusSy3gSdW9Jq5Lbq15tZGcuBUHTADDcNY87IpBJbHx5l1yTxaU/nvGWCGPcQq YGb6OHhRLL/658ziaghyZJF/0vJ2L8ggQn36sn085LGeWy6HieEyLDZbO84Uyfegpvd+ j2gb9fP62hAx1D/aGKgtP2Pm967faZK9tY8RUQLr+KrMyR2QVbM0fb8FaT2EUFT76NeU NznQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=fxakradHXFMEPvkT0xe7n1MvjA07iD3Xlj7rhy6xFHU=; b=lrXiUIyAv9xcynFjW08xq26Hrg7PJbRvEvPWsqomoB7C9lIRNZyCfaPh5o2KFLbE44 b/k1M2xOOHQ+3xID6NW5kyYuq+YLh6iL6yf3Ym9za93myMsIwSoyv9Hqq/4GFZRmyAXi o5hJQTFgfEt9KxcMKYQS11c0RywHRxGU+usXtKQLiUentrZA3ICh3OrH+vx59wO1huKW Inlw3ji2rBOE5V/Y7dXIcsYzarjG8KTsPhrx9sfHNraGneb6TCPUZaillQMrtV/wYazD Qupt9S5+SMzZHrpGJ41eVd2VasULjTzgrqJefocYkTx7DJPqNENRSbYhT/GTIhEJVOP+ rPtg== X-Gm-Message-State: APjAAAUYRyEvejJ2W9glqc1+fLHVR7xzs7FGUpP5geKBTErBhvqBYrSV yU/8vUBMf0SpY23oPgd38+8Gt1PhUVU= X-Google-Smtp-Source: APXvYqxFhcihjGQ7Z/12zPJ3TBwa2jaHrLktYu4CWwoG5S5Nq0r7ZaZfg58bMdoXFLXeWYFmn8p7rA== X-Received: by 2002:aa7:9577:: with SMTP id x23mr55039345pfq.164.1558025971021; Thu, 16 May 2019 09:59:31 -0700 (PDT) Received: from [192.168.2.201] (static-50-53-109-254.bvtn.or.frontiernet.net. [50.53.109.254]) by smtp.googlemail.com with ESMTPSA id r1sm5249905pfg.65.2019.05.16.09.59.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 May 2019 09:59:30 -0700 (PDT) Subject: Re: schema change tracking To: pgsql-general@lists.postgresql.org References: From: Paul Jungwirth Message-ID: <2ee69bab-73f2-5455-04bb-38db8a317789@illuminatedcomputing.com> Date: Thu, 16 May 2019 09:59:29 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.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 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 5/16/19 9:41 AM, Benedict Holland wrote: > I need a tool that can track schema changes in a postgesql database, > write scripts to alter the tables, and store those changes in git. Are > there tools that exist that can do this? > > BTW, I know if I use a framework with some form of model tracking > (laravel and Django), those can do it. The application I am writing does > not track model files and I really cannot compare sql schema dumps > across versions. It would be far too time-consuming. For Python database migrations when I'm not using Django or SQLAlchemy I've enjoyed yoyo migrations: https://ollycope.com/software/yoyo/latest/ If you are using SQLAlchemy then I'd go with Alembic: https://pypi.org/project/alembic/ Btw I don't *think* this is what you're looking for, but on the Postgres side you can also set `log_statement='ddl'` to audit the changes: https://blog.hagander.net/why-are-you-not-logging-your-ddl-142/ Or for something more elaborate you could use Event Triggers. The docs have an example you could start from: https://www.postgresql.org/docs/current/event-trigger-example.html -- Paul ~{:-) pj@illuminatedcomputing.com