diff --git a/backend/app.py b/backend/app.py index b5b8f3c..c704614 100644 --- a/backend/app.py +++ b/backend/app.py @@ -796,11 +796,6 @@ def export_data(data_type): df.to_csv(output_file, index=False) return send_from_directory('/tmp', f'{data_type}_{vehicle_id}.csv', as_attachment=True) -if __name__ == '__main__': - with app.app_context(): - db.create_all() - app.run(host='0.0.0.0', port=5000, debug=False) - # Edit/Delete operations for Service Records @app.route('/api/vehicles//service-records/', methods=['GET', 'PUT', 'DELETE']) @login_required @@ -902,3 +897,8 @@ def reminder_operations(vehicle_id, reminder_id): db.session.delete(reminder) db.session.commit() return jsonify({'message': 'Reminder deleted successfully'}) + +if __name__ == '__main__': + with app.app_context(): + db.create_all() + app.run(host='0.0.0.0', port=5000, debug=False) diff --git a/backend/entrypoint.sh b/backend/entrypoint.sh index 75115e3..eecbf25 100755 --- a/backend/entrypoint.sh +++ b/backend/entrypoint.sh @@ -14,6 +14,10 @@ echo "Initializing database..." cd /app/backend python init_db.py +# Run migrations +echo "Running database migrations..." +python migrate_attachments.py + # Set database file permissions if [ -f /app/data/masina_dock.db ]; then chmod 666 /app/data/masina_dock.db