Migrate the database schema to SQLAlchemy

The new schema was generated with sqlacodegen and then manually adjusted
to fit schema/aur-schema.sql faithfully, both in the organisation of the
code and in the SQL generated by SQLAlchemy.

Initializing the database now requires the new tool aurweb.initdb.
References to aur-schema.sql have been updated and the old schema
dropped.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
Frédéric Mangano-Tarumi 2020-02-16 21:56:10 +01:00 committed by Lukas Fleischer
parent 4b2102ceb2
commit 7188743fc3
10 changed files with 481 additions and 482 deletions

View file

@ -110,10 +110,7 @@ SSH_TTY=/dev/pts/0
export SSH_CLIENT SSH_CONNECTION SSH_TTY
# Initialize the test database.
DBSCHEMA="$TOPLEVEL/schema/aur-schema-sqlite.sql"
[ -f "$DBSCHEMA" ] || error 'SQLite database schema not found'
rm -f aur.db
sqlite3 aur.db <"$DBSCHEMA"
python -m aurweb.initdb
echo "INSERT INTO Users (ID, UserName, Passwd, Email, LangPreference, AccountTypeID) VALUES (1, 'user', '!', 'user@localhost', 'en', 1);" | sqlite3 aur.db
echo "INSERT INTO Users (ID, UserName, Passwd, Email, LangPreference, AccountTypeID) VALUES (2, 'tu', '!', 'tu@localhost', 'en', 2);" | sqlite3 aur.db