diff --git a/alembic/versions/cdf401a636ea_.py b/alembic/versions/cdf401a636ea_.py deleted file mode 100644 index 61b7604..0000000 --- a/alembic/versions/cdf401a636ea_.py +++ /dev/null @@ -1,40 +0,0 @@ -"""empty message - -Revision ID: cdf401a636ea -Revises: -Create Date: 2025-03-14 04:16:49.143794 - -""" -from typing import Sequence, Union - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision: str = 'cdf401a636ea' -down_revision: Union[str, None] = None -branch_labels: Union[str, Sequence[str], None] = None -depends_on: Union[str, Sequence[str], None] = None - - -def upgrade() -> None: - """Upgrade schema.""" - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('log', - sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), - sa.Column('user_id', sa.Integer(), nullable=False), - sa.Column('datetime', sa.TIMESTAMP(timezone=True), nullable=False), - sa.Column('action', sa.Enum('FIRST_ENTRY', 'REGISTRATION', 'LOGIN', 'LOGOUT', 'CREATE_THEME', 'ENTRY_THEME', 'DELETE_THEME', 'WRITE_MESSAGE', name='useractions'), nullable=False), - sa.Column('object_id', sa.Integer(), nullable=True), - sa.Column('response', sa.SMALLINT(), nullable=False), - sa.PrimaryKeyConstraint('id') - ) - # ### end Alembic commands ### - - -def downgrade() -> None: - """Downgrade schema.""" - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('log') - # ### end Alembic commands ### diff --git a/dumps/dump.sql b/dumps/dump.sql index 67e51b8..291fad8 100644 --- a/dumps/dump.sql +++ b/dumps/dump.sql @@ -39,16 +39,6 @@ SET default_tablespace = ''; SET default_table_access_method = heap; --- --- Name: alembic_version; Type: TABLE; Schema: public; Owner: postgres --- - -CREATE TABLE public.alembic_version ( - version_num character varying(32) NOT NULL -); - - -ALTER TABLE public.alembic_version OWNER TO postgres; -- -- Name: log; Type: TABLE; Schema: public; Owner: postgres @@ -56,7 +46,7 @@ ALTER TABLE public.alembic_version OWNER TO postgres; CREATE TABLE public.log ( id integer NOT NULL, - user_id integer NOT NULL, + user_id integer, datetime timestamp with time zone NOT NULL, action public.useractions NOT NULL, object_id integer, @@ -94,33 +84,18 @@ ALTER SEQUENCE public.log_id_seq OWNED BY public.log.id; ALTER TABLE ONLY public.log ALTER COLUMN id SET DEFAULT nextval('public.log_id_seq'::regclass); - --- --- Data for Name: alembic_version; Type: TABLE DATA; Schema: public; Owner: postgres --- - -INSERT INTO public.alembic_version (version_num) VALUES ('cdf401a636ea'); - - -- -- Data for Name: log; Type: TABLE DATA; Schema: public; Owner: postgres -- +INSERT INTO public.log (id, user_id, datetime, action, object_id, response) VALUES (1, 2, '2025-03-13 18:34:34.443097+00', 'FIRST_ENTRY', NULL, 200); -- -- Name: log_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres -- -SELECT pg_catalog.setval('public.log_id_seq', 1, false); - - --- --- Name: alembic_version alembic_version_pkc; Type: CONSTRAINT; Schema: public; Owner: postgres --- - -ALTER TABLE ONLY public.alembic_version - ADD CONSTRAINT alembic_version_pkc PRIMARY KEY (version_num); +SELECT pg_catalog.setval('public.log_id_seq', 1, true); -- diff --git a/src/database_adapter/model.py b/src/database_adapter/model.py index 06ee281..0277cf2 100644 --- a/src/database_adapter/model.py +++ b/src/database_adapter/model.py @@ -25,7 +25,7 @@ class Base(DeclarativeBase): class Log(Base): __tablename__ = "log" id: Mapped[int] = mapped_column(INTEGER, primary_key=True, autoincrement=True) - user_id: Mapped[int] + user_id: Mapped[int] = mapped_column(nullable=True) date_time: Mapped[datetime] = mapped_column( "datetime", TIMESTAMP(timezone=True), default=utc_signed_now )