java - 我在 Docker 容器中找不到 postgresql 表
问题描述
有一个Java项目。这个项目不是我的。我正在努力对付他。有授权服务:
spring:
profiles:
active: @spring.profiles.active@
jpa:
hibernate:
ddl-auto: none
datasource:
initialization-mode: always
platform: authentication
driver-class-name: org.postgresql.Driver
username: postgres
password: postgres
url: jdbc:postgresql://localhost:5432/mark_authentication
jdbc-url: jdbc:postgresql://localhost:5432/mark_authentication
liquibase:
change-log: classpath:db/changelog.xml
这是 liquibase 的文件
<changeSet id="create_roles" author="afanasev">
<createTable tableName="roles" schemaName="users">
<column name="id" type="BIGINT" autoIncrement="true">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="role_name" type="varchar(25)"/>
</createTable>
<insert schemaName="users"
tableName="roles">
<column name="id" value="0"/>
<column name="role_name" value="ROLE_SUBSCRIBER"/>
</insert>
<insert schemaName="users"
tableName="roles">
<column name="id" value="1"/>
<column name="role_name" value="ROLE_MARKETPLACE"/>
</insert>
<insert schemaName="users"
tableName="roles">
<column name="id" value="2"/>
<column name="role_name" value="ROLE_ADMIN"/>
</insert>
</changeSet>
<changeSet id="create_users" author="afanasev">
<createTable tableName="users" schemaName="users">
<column name="id" type="VARCHAR(255)" autoIncrement="false">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="password" type="VARCHAR(50)">
<constraints nullable="false"/>
</column>
<column name="email" type="VARCHAR(50)">
<constraints nullable="false"/>
</column>
<column name="full_name" type="VARCHAR(255)">
<constraints nullable="false"/>
</column>
<column name="is_active" type="boolean" defaultValueBoolean="false">
<constraints nullable="false"/>
</column>
<column name="date_added" type="timestamp" defaultValueComputed="current_timestamp">
<constraints nullable="false"/>
</column>
<column name="id_role" type="INT">
<constraints nullable="false" foreignKeyName="fk_role" referencedTableSchemaName="users" referencedTableName="roles" referencedColumnNames="id"/>
</column>
<column name="code" type="int"/>
</createTable>
</changeSet>
<changeSet id="update_users" author="afanasev">
<addColumn tableName="users" schemaName="users">
<column name="address" type="VARCHAR(255)"/>
</addColumn>
<addColumn tableName="users" schemaName="users">
<column name="tax_identification_number" type="BIGINT"/>
</addColumn>
<addColumn tableName="users" schemaName="users">
<column name="organization" type="VARCHAR(255)"/>
</addColumn>
<addColumn tableName="users" schemaName="users">
<column name="msisdn" type="BIGINT"/>
</addColumn>
<addColumn tableName="users" schemaName="users">
<column name="code_reason" type="BIGINT"/>
</addColumn>
</changeSet>
这是 docker-compose 文件
postgres-authentication:
container_name: postgres-authentication
image: postgres:13.2-alpine
restart: unless-stopped
ports:
- "5433:5432"
environment:
- POSTGRES_USER=postgres
- POSTGRES_DB=authentication
- POSTGRES_PASSWORD=postgres
volumes:
- ./postgres_authentication_data:/var/lib/postgresql/data
该应用程序正在服务器上运行和旋转。我进入码头集装箱
docker exec -it postgres-authentication bash
连接到数据库
\c authentication
我在那里看不到任何表格,除了日志
\dt
Schema | Name | Type | Owner
--------+-----------------------+-------+----------
public | databasechangelog | table | postgres
public | databasechangeloglock | table | postgres
我查看日志,更改日志在那里工作并且表已经创建。
create_roles | afanasev | db/changelog/01-create-user.xml | 2021-07-01 20:03:45.70403 | 1 | EXECUTED | 8:f576f05834bc714dda20a2e6580fd2de | createTable tableName=roles; insert tableName=roles; insert tableName=roles; insert tableName=roles | | | 3.10.3 | | | 5169825313
create_users | afanasev | db/changelog/01-create-user.xml | 2021-07-01 20:03:46.039663 | 2 | EXECUTED | 8:f0f6055fe52f20bd3123bb53b38071de | createTable tableName=users | | | 3.10.3 | | | 5169825313
事实上,我正在注册并且它可以工作,即它添加了一个用户,我可以在它下面登录。但是这些桌子在哪里呢?也许我不在那儿看?
解决方案
使用时\dt
,默认只显示public
架构
如果要显示所有架构表,则应使用\dtS
或使用\dt [PATTERN]
如果使用\dtS
,您会看到数据库的所有架构都包括 Postgres 架构,例如pg_catalog
但是如果使用\dt [PATTERN]
,您可以看到与您的预期匹配的模式模式。如下所示:
-- just show users schema
\dt users
推荐阅读
- tensorflow - 无法加载动态库“libcublas.so.10”;dlerror:libcublas.so.10:无法打开共享对象文件:没有这样的文件或目录;
- rest - 使用 SQLAlchemy 的 Flask REST API 中的整数范围
- python - 使用 python emoji 包无法正确显示表情符号
- python - 使用请求 api 到我可以迭代的 json 文件中
- javascript - 异常“Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException”
- python - 如何将列名及其值拆分到不同的列而不是多合一(熊猫)
- java - 改造 2 使用不总是 XML 或 Json 的响应
- xamarin.forms - Xamarin.Forms - 显示所有项目而不滚动
- node.js - database.ts 中出现意外的令牌 const
- javascript - 为什么在第一个 `it` it 回调之后`render(...)` 结果会改变?