[aur-dev] [PATCH 1/2] aur-schema.sql: Do not recreate the database
Modify the schema such that it only creates the necessary tables, indices and predefined data. This makes it easier to import the schema into a database with a name other than "AUR". Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- schema/aur-schema.sql | 3 --- 1 file changed, 3 deletions(-) diff --git a/schema/aur-schema.sql b/schema/aur-schema.sql index b75a257..418e532 100644 --- a/schema/aur-schema.sql +++ b/schema/aur-schema.sql @@ -1,9 +1,6 @@ -- The MySQL database layout for the AUR. Certain data -- is also included such as AccountTypes, etc. -- -DROP DATABASE IF EXISTS AUR; -CREATE DATABASE AUR DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; -USE AUR; -- Define the Account Types for the AUR. -- -- 2.12.0
Allow for automatically converting the schema into a schema that works with SQLite by running `make` from the schema/ subdirectory. Use the new Makefile in the test suite. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- schema/Makefile | 11 +++++++++++ test/Makefile | 8 ++++++-- test/setup.sh | 9 +-------- 3 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 schema/Makefile diff --git a/schema/Makefile b/schema/Makefile new file mode 100644 index 0000000..e0448ad --- /dev/null +++ b/schema/Makefile @@ -0,0 +1,11 @@ +aur-schema-sqlite.sql: aur-schema.sql + sed \ + -e 's/ ENGINE = InnoDB//' \ + -e 's/ [A-Z]* UNSIGNED NOT NULL AUTO_INCREMENT/ INTEGER NOT NULL/' \ + -e 's/([0-9, ]*) UNSIGNED / UNSIGNED /' \ + $< >$@ + +clean: + rm -rf aur-schema-sqlite.sql + +.PHONY: clean diff --git a/test/Makefile b/test/Makefile index d6f0f74..4ce9b9b 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,6 +1,10 @@ +FOREIGN_TARGETS = ../schema/aur-schema-sqlite.sql T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)) -check: $(T) +check: $(FOREIGN_TARGETS) $(T) + +$(FOREIGN_TARGETS): + $(MAKE) -C $(dir $@) $(notdir $@) clean: $(RM) -r test-results/ @@ -8,4 +12,4 @@ clean: $(T): @echo "*** $@ ***"; $(SHELL) $@ -.PHONY: check clean $(T) +.PHONY: check $(FOREIGN_TARGETS) clean $(T) diff --git a/test/setup.sh b/test/setup.sh index 2959a4e..64ba88f 100644 --- a/test/setup.sh +++ b/test/setup.sh @@ -106,14 +106,7 @@ export SSH_CLIENT SSH_CONNECTION SSH_TTY # Initialize the test database. rm -f aur.db -sed \ - -e '/^DROP DATABASE /d' \ - -e '/^CREATE DATABASE /d' \ - -e '/^USE /d' \ - -e 's/ ENGINE = InnoDB//' \ - -e 's/ [A-Z]* UNSIGNED NOT NULL AUTO_INCREMENT/ INTEGER NOT NULL/' \ - -e 's/([0-9, ]*) UNSIGNED / UNSIGNED /' \ - "$TOPLEVEL/schema/aur-schema.sql" | sqlite3 aur.db +sqlite3 aur.db <"$TOPLEVEL/schema/aur-schema-sqlite.sql" echo "INSERT INTO Users (ID, UserName, Passwd, Email, AccountTypeID) VALUES (1, 'user', '!', 'user@localhost', 1);" | sqlite3 aur.db echo "INSERT INTO Users (ID, UserName, Passwd, Email, AccountTypeID) VALUES (2, 'tu', '!', 'tu@localhost', 2);" | sqlite3 aur.db -- 2.12.0
participants (1)
-
Lukas Fleischer