gpt4 book ai didi

postgresql - Play Framework 2.6 中未触发 Slick (postgresql) 演变

转载 作者:行者123 更新时间:2023-11-29 12:17:06 28 4
gpt4 key购买 nike

这里是数据库配置

应用程序配置文件:

slick.dbs.default.profile="slick.jdbc.PostgresProfile$"
slick.dbs.default.db.driver="org.postgresql.Driver"
slick.dbs.default.db.url="jdbc:postgresql://localhost:5432/postgres"
slick.dbs.default.db.user=postgres
slick.dbs.default.db.password=postgres

build.sbt

name := """myproject"""
version := "1.0-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayScala)

resolvers += Resolver.sonatypeRepo("snapshots")

scalaVersion := "2.12.4"

libraryDependencies += guice
libraryDependencies += evolutions

libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "3.0.0" % Test


libraryDependencies += "org.postgresql" % "postgresql" % "42.1.4"
libraryDependencies += "com.typesafe.play" %% "play-slick" % "3.0.1"
libraryDependencies += "com.typesafe.play" %% "play-slick-evolutions" % "3.0.1"

我在 conf/evolutions/default 文件夹中有 sql 脚本

1.sql

# Users schema

# --- !Ups

CREATE TABLE users
(
id bigint NOT NULL,
email character varying(255) NOT NULL,
username character varying(100) NOT NULL,
password character varying(100) NOT NULL,
PRIMARY KEY (id)
)
WITH (
OIDS = FALSE
);

# --- !Downs

DROP TABLE IF EXISTS users CASCADE;

但是在应用程序启动时,不会触发进化。数据库连接工作正常(我已经通过从这个应用程序对数据库实现一些巧妙的查询进行了检查)。

我在这里做错了什么?

最佳答案

尝试将这一行添加到您的 application.conf 中:

play.evolutions.db.default.enabled = true

关于postgresql - Play Framework 2.6 中未触发 Slick (postgresql) 演变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47467450/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com