473,387 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Using a Makefile during database development

Hello again,

I'm developing a program based on PostgreSQL. It's consists of tables,
constraints, _many_ stored procedures, 56M of test data, and a client
app written in C.

To help me with all of this, I obviously have a Makefile. I can do
"make" to rebuild the C app (assuming I haven't added any bugs) and I
can do "make database" to create the database tables, and "make funcitons"
to add the stored procedures to the database, and I'll soon be adding
"make test" to install the test data. When I get to the constraints,
I'll make a target for it as well.

There's probably no reason for me to explain the advantages of these
targets during development :)

However, in order to do "make database" I have to first drop the current
database. In order to do "make functions" I (currently) have to drop
and recreate the database. I figure I'll have to do the same for
"make test" once I've added that target to the makefile.

I'm wondering if anyone has some examples making targets like this
more automatic. For example, if I do "make db-all" would test the various
files that have the table, constraint, stored procedure, and test data
in them and if any had been updated, only then rebuild that portion of
the database. Frankly, there's enough stuff already that it's getting time
consuming to rebuild everything when I make changes, and I get
interrupted in my work too often to easily keep track of what I've
updated since I last did it.

The problem I'm hitting is this: how can I teach make to know when a
particular file is newer than the data in the database? Until I can
figure out a system for that, I can't really automate any more of the
process.

Anyone have a technique they've been using?

--
Bill Moran
Potential Technologies
http://www.potentialtech.com
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 22 '05 #1
2 1636
Bill Moran <wm****@potentialtech.com> writes:
The problem I'm hitting is this: how can I teach make to know when a
particular file is newer than the data in the database?


AFAIK there's no direct way to do that; all of make's decisions are
based on existence and mod times of files, so you can't persuade it to
test directly for SQL-level conditions.

However, this sort of problem comes up in many contexts, and make users
have developed a standard solution: you create or touch an empty
"timestamp" file when you do an action such as updating the database
from a particular collection of source files. The mod time of the
timestamp file can then serve as the comparison value telling make
whether to do it again. A typical rule would look like:

db_update.stamp: somefile.sql someotherfile.sql
psql mydb -f somefile.sql
psql mydb -f someotherfile.sql
touch db_update.stamp

You make one stamp file for each action you might or might not need to
do, and then user-level targets look like

update: db_update.stamp ...

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 22 '05 #2
Tom Lane wrote:
Bill Moran <wm****@potentialtech.com> writes:
The problem I'm hitting is this: how can I teach make to know when a
particular file is newer than the data in the database?

AFAIK there's no direct way to do that; all of make's decisions are
based on existence and mod times of files, so you can't persuade it to
test directly for SQL-level conditions.

However, this sort of problem comes up in many contexts, and make users
have developed a standard solution: you create or touch an empty
"timestamp" file when you do an action such as updating the database
from a particular collection of source files. The mod time of the
timestamp file can then serve as the comparison value telling make
whether to do it again. A typical rule would look like:

db_update.stamp: somefile.sql someotherfile.sql
psql mydb -f somefile.sql
psql mydb -f someotherfile.sql
touch db_update.stamp

You make one stamp file for each action you might or might not need to
do, and then user-level targets look like

update: db_update.stamp ...


Thanks, Tom.

I had considered this approach, but it seemed rather clunky. The way you
describe it doesn't make it sound so bad, though.

I was hoping there was some way to track this using a backticked command
or something.

--
Bill Moran
Potential Technologies
http://www.potentialtech.com
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Griff | last post by:
Hi there I'm trying to run some CGI programs under Apache, written in C++, which use the "libmysqlclient" MySQL library. This is all running on Solaris. I build my programs using the...
5
by: Tony Wright | last post by:
Hi, I am having a problem installing an msi for a web site. The error message I am getting is: "The specified path 'http://mipdev05/features/Fas2' is unavailable. The Internet Information...
2
by: xuatla | last post by:
Is it off-topic here or not? If not, please help me. Thanks in advance. X -------------------- I have main.cpp, tfunclib.cpp in the current folder (same as makefile), and "library files"...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
13
by: Andrew | last post by:
I use conditional compiler constants, set through the VBA IDE in Tools, <projectname> Properties, that I refer to throughout my code to control which code is used during development, and which...
9
by: silversurfer | last post by:
Hello world, I was just wondering why the clear-line in my Makefile does not work: main:main.o $(ADDOBJS) clear @g++ -o main $(LDFLAGS) $+ As far as I understood it, it should be possible to...
2
by: call_me_anything | last post by:
hi, We have a big project thats built on several platforms and has a huge number of files - common and platform specific files. It compiles well if compiled through command line by its makefile....
20
by: Rob Stevens | last post by:
Can someone tell me how to import the sqlite3.dll file into c#. I am pretty new to this, and I want to use sqlite. The problem is I don't have a clue on how to import the dll file so i can call...
16
by: pereges | last post by:
Do you see anything wrong about this method ? For eg. I write a shell script a.sh containing : cc -o test file1.c file2.c file3.c and then execute the shell script ( sh a.sh) to compile and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.